首页 > 代码库 > php删除字符串中的所有空格

php删除字符串中的所有空格

<?php
function trimall($str)//删除空格
{
    $qian=array(" "," ","\t","\n","\r");$hou=array("","","","","");
    return str_replace($qian,$hou,$str);   
}
$i="  heasdfj   jasdf  ajsdo ";
$j=trimall($i);
echo $j;
?>

php删除字符串中的所有空格