我当然有两个字空间,前后有很多空格,我需要做的是删除之前和之后的空格,而不需要介于两者之间.
如何删除之前和之后的空格?
我有一个数组巫婆匹配字符串占位符如下:
"some text %s another text %s extra text %s"
Run Code Online (Sandbox Code Playgroud)
和数组:
$array[0] match the first %s
$array[1] match the second %s
$array[2] match the third %s
Run Code Online (Sandbox Code Playgroud)
我认为可以使用sprintf函数完成如下:
$content = sprintf("some text %s another text %s extra text %s", $array);
Run Code Online (Sandbox Code Playgroud)
但这会返回太少的参数错误,我试图使用implode:
$content = sprintf("some text %s another text %s extra text %s", implode(",",$array));
Run Code Online (Sandbox Code Playgroud)
提前致谢