1、去除两边的空格
$arr=" shhs ";
trim($arr)
2、正则匹配去除所有的空格
$goodid =“ ceshi ”;
$res=preg_replace('# #','',$goodid)
print_r($res);
结果:
ceshi
第2种方案比较好,第一个trim 只能去掉左右的空格,但是不能去掉所有的,方案2,能去掉所以的空格;
1、去除两边的空格
$arr=" shhs ";
trim($arr)
2、正则匹配去除所有的空格
$goodid =“ ceshi ”;
$res=preg_replace('# #','',$goodid)
print_r($res);
结果:
ceshi
第2种方案比较好,第一个trim 只能去掉左右的空格,但是不能去掉所有的,方案2,能去掉所以的空格;