php 删除所有空格

function trimall($str)//删除空格
{
    $oldchar=array(" "," ","\t","\n","\r");
$newchar=array("","","","","");
    return str_replace($oldchar,$newchar,$str);
}

测试:
$str = " a b c d e f ";
echo trimall($str);

输出结果:
abcdef
上一篇:PHP写入文件


下一篇:PHP 获取字符串长度