浏览模式: 普通 | 列表
7月, 2014 | 1
php多个连续空格(&nbsp;)或者分段<br/>替换为一个。如何改写下面这个更加简短?
function re($content)
{
         /* return preg_replace('/(<br\s*\/?>){3,}|(&nbsp;){3,}/i'),'\\1',$content); */ //错误!
         /* return preg_replace('/(<br\s*\/?>|&nbsp;){3,}/i'),'\\1',$content); */ //错误!
         return preg_replace(array('/(<br\s*\/?>){3,}/i','/(&nbsp;){3,}/i'),'\\1',$content);
}


//test
$content = '1111&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br
...

阅读全文…
1