如何将$string
"one two three"进入:
"one two three"发布于 2011-12-20 13:56:18
$str = "one two three";
$str = preg_replace('/ +/',' ',$str);这将用一个空格替换一个或多个空格。它还将用它自己替换单个空格!!要改进它,请执行以下操作:
$str = preg_replace('/ {2,}/',' ',$str);它用单个空格替换了一组2个或更多个连续空格。
发布于 2011-12-20 14:11:12
试试这个:
$str = preg_replace("/[ ]{2,}/", " ", $str);https://stackoverflow.com/questions/8571347
复制相似问题