有没有PHP函数可以去除字符串中的空格?例如:
我想获取字符串:
如何做到这一点?
$abcd="this is a test"
我想获取字符串:
$abcd="thisisatest"
如何做到这一点?
$abcd = str_replace(' ', '', 'this is a test');
$abcd="this is a test";
$abcd = preg_replace('/( *)/', '', $abcd);
echo $abcd."\n"; //Will output 'thisisatest';
$abcd = preg_replace('/\s/', '', $abcd);
$string = preg_replace('/\s+/', '', $string);