$str = " This line contains\tliberal \r\n use of whitespace.\n\n";
// 移除前後空白字
$str = trim($str);
// 移除重覆的空白
$str = preg_replace('/\s(?=\s)/', '', $str);
// 移除非空白的間距變成一般的空白
$str = preg_replace('/[\n\r\t]/', ' ', $str);
// Echo out: 'This line contains liberal use of whitespace.'
echo " {$str} ";
////移除所有空白
$chinese_name = " 我是 sdf sdfsf555 誰333";
$chinese_name = str_replace(" ","",$chinese_name);
?>
|