[英]PHP - How to add a specific character at the end of a string?
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
. 我想让AddToEnd
出现在$string
的最后一个字符之后。
How it is possible, thanks in advance! 怎么可能,在此先感谢!
See PHP's String Operators to see how to concatenate strings: 请参阅PHP的字符串运算符以了解如何连接字符串:
$finalString = $string . $AddToEnd;
// OR
$string .= $AddToEnd
You can also use a function like implode()
: 您还可以使用implode()
类的函数:
$finalString = implode(array($string, $AddToEnd));
What you're looking for is called concatenation. 您要查找的内容称为串联。
In PHP you have ms to do that : 在PHP中,您可以执行以下操作:
$concat = $string . $AddToEnd;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.