Just wondering if there is something like .= for adding text to the beginning of a string, e.g.:
$foo =. 'bar';
which doesn't work.
Edit: example was originally $foo =. $bar;
which can be achieved with $bar .= $foo;
Method 1: Using Concatenation Operator(“.”): The Concatenation operator is used to prepend a string str1 with another string str2 by concatenation of str1 and str2.
There is no specific function to append a string in PHP. In order to do this task, we have the this operator in PHP: Using Concatenation assignment operator (“. =”): The Concatenation assignment operator is used to append a string str1 with another string str2.
To get the first n characters of a string, we can use the built-in substr() function in PHP. Here is an example, that gets the first 3 characters from a following string: <? php echo substr("Google", 0, 3); ?>
There are two string operators. The first is the concatenation operator ('. '), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator (' . = '), which appends the argument on the right side to the argument on the left side.
Nope. But you can do
$foo = "bar" . $foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With