您是指空格还是所有空格?
对于仅空格,请使用str_replace:
$string = str_replace(' ', '', $string);对于所有空格(包括制表符和行尾),请使用preg_replace:
$string = preg_replace('/s+/', '', $string);
您是指空格还是所有空格?
对于仅空格,请使用str_replace:
$string = str_replace(' ', '', $string);对于所有空格(包括制表符和行尾),请使用preg_replace:
$string = preg_replace('/s+/', '', $string);