I am looking for hours how can i add an specific character at the end of a string.
Here is my code:
$string = "I have a";
$AddToEnd = "]";
I want to make AddToEnd
to appear after the last character in $string
.
How it is possible, thanks in advance!
What you're looking for is called concatenation.
In PHP you have ms to do that :
$concat = $string . $AddToEnd;
See PHP's String Operators to see how to concatenate strings:
$finalString = $string . $AddToEnd;
// OR
$string .= $AddToEnd
You can also use a function like implode()
:
$finalString = implode(array($string, $AddToEnd));
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