PHP多个连续空格回车替换为一个,怎么写更简短

WBOY
Release: 2016-06-13 11:56:06
Original
1707 people have browsed it

PHP多个连续空格回车替换为一个,如何写更简短?
php多个连续空格( )或者分段
替换为一个。如何改写下面这个更加简短?

<br /><br />function re($content)<br />{<br />    /* return preg_replace('/(<br\s*\/?>){3,}|( ){3,}/i'),'\\1',$content); */ //错误!<br />    /* return preg_replace('/(<br\s*\/?>| ){3,}/i'),'\\1',$content); */ //错误!<br />    return preg_replace(array('/(<br\s*\/?>){3,}/i','/( ){3,}/i'),'\\1',$content);<br />}<br /><br /><br />//test<br />$content = '1111    <br><br><br><br />@@@<br/><br><br/><br>aaaaM<br><br/>';<br />echo re($content);<br />exit();<br />
Copy after login

------解决方案--------------------
已经很短了,还要改什么呢。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template