Home >Backend Development >PHP Tutorial >php remove all spaces in string trimall
In fact, it is an extension of the trim function
trim can only remove spaces on both sides of the string
<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>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
The above introduces PHP trimall to delete all spaces in a string, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.