去除内容中所有的多余的空格和空行
PHP代码
- php > $str = "a b c d\n\ne f g \t 2";
- php > echo preg_replace('/\s+/',' ',$str);
- a b c d e f g 2
- php > echo $str;
- a b c d
- e f g 2
- php > echo preg_replace('/(\s)+/','$1',$str);
- a b c d
- e f g 2
应该没有写错
Submitted by gouki on 2016, September 7, 10:19 AM. PHP
去除内容中所有的多余的空格和空行