PHP多个连续空格回车替换为一个,如何写更简短?
[ 2014-07-14 22:38:28 | 作者: admin ]
php多个连续空格( )或者分段<br/>替换为一个。如何改写下面这个更加简短?
阅读全文…
function re($content)
{
/* return preg_replace('/(<br\s*\/?>){3,}|( ){3,}/i'),'\\1',$content); */ //错误!
/* return preg_replace('/(<br\s*\/?>| ){3,}/i'),'\\1',$content); */ //错误!
return preg_replace(array('/(<br\s*\/?>){3,}/i','/( ){3,}/i'),'\\1',$content);
}
//test
$content = '1111 <br><br><br><br
...{
/* return preg_replace('/(<br\s*\/?>){3,}|( ){3,}/i'),'\\1',$content); */ //错误!
/* return preg_replace('/(<br\s*\/?>| ){3,}/i'),'\\1',$content); */ //错误!
return preg_replace(array('/(<br\s*\/?>){3,}/i','/( ){3,}/i'),'\\1',$content);
}
//test
$content = '1111 <br><br><br><br
阅读全文…
1