How can I use the += operator for a string in PHP?
Below is a Java example:
String str = "";
str += "some value";
str += "some more values";
The above example concatenates and assign all values to the str
object.
How can I achieve this in PHP?
You are searching for .=
:
$str = "";
$str .= "some value";
$str .= "some value";
$str .= "some more values";
Either:
$str = $str + "stuff";
Or:
$str .= "stuffsicles";
精彩评论