连续回车:
$str = "开始
内容
结束";
$str = preg_replace("/\s+\r/is", "\n", $str);//回车符是\r
$str = preg_replace("/\s+\r\n/is", "\n", $str);//回车符是\r\n
$str = preg_replace("/\s+\n/is", "\n", $str);//回车符是\n
$str = str_replace("\n",'<br />',$str);
连续空格:
必须是两个或者两个以上才去掉:
$str
=
"a b d\nc"
;
echo
preg_replace(
'#\s{2,}#'