其实是对trim函数的扩展
trim只能删除字符串两边的空格
<code><span>//删除所有空格</span><span><span>function</span><span>trimall</span><span>(<span>$str</span>)</span>{</span><span>$qian</span>=<span>array</span>(<span>" "</span>,<span>" "</span>,<span>"\t"</span>,<span>"\n"</span>,<span>"\r"</span>);<span>$hou</span>=<span>array</span>(<span>""</span>,<span>""</span>,<span>""</span>,<span>""</span>,<span>""</span>); <span>return</span> str_replace(<span>$qian</span>,<span>$hou</span>,<span>$str</span>); }</code>
以上就介绍了php删除字符串中的所有空格 trimall,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。