方法1:使用str_ireplace()函数
<?php $str = 'hello world !'; $search = ' '; $replace = ''; echo str_ireplace($search, $replace, $str); ?>
输出:
helloworld!
方法2:使用str_replace()函数
<?php
$str = 'hello world !';
$str = str_replace(' ', '', $str);
echo $str;
?>
输出:
helloworld!

