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