php删除连续空格
对字段中的连续空格进行删除只保留一个。
应用案例
$txt=" a b c ytecn 1"; $name=RemoveMoreSpaces($sss); echo $name;
输出结果为:a b c ytecn 1
函数
/** * 删除连续空格 * @param $s * @return null|string|string[] */ function RemoveMoreSpaces($s) { return preg_replace("/\s(?=\s)/", "\\1", $s); }