Home > Article > Backend Development > How to remove php regular expression br
##The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computerphp Regular way to remove br: First create a PHP sample file; then use the str_replace function and the regular expression "str_replace("e388a4556c0f65e1904146cc1a846beec16cfaf09ec2901d2f76abdf1ba64e098a45c867fd727fc770712bce9321033f" ,"",$htmlstr);" just replace br.
\>
phpRegular How to remove br?
How does PHP's str_replace function replace e388a4556c0f65e1904146cc1a846bee076402276aae5dbec7f672f8f4e5cc8194b3e26ee717c64999d7867364b1b4a3? The code is as follows:$html="<p>fdasf</p>"; echo $string = str_replace(array("<p>","","</p>"),"",$html); br<http://bbs.houdunwang.com/> 若是<p> 内容</p>替换成<p>内容</p><p> content</p>替换成<p>contend</p>(空格是tab键和空格键 混合的 都有可能)方法如下 $html=preg_replace('/[\n\r\t]/','',$html);//去空格 若是<p>后面跟了若干个,再是内容 <p> 内容</p> 替换成<p>内容</p> <p> content</p> 替换成<p>contend</p> <?php $html="<p> 内容</p>替换成<p>内容</p> <p>content</p>替换成<p>contend</p>";方法如下 $html=trim($html); $html=str_replace(PHP_EOL,"",$html); $html=str_replace(" ","",$html); $html=preg_replace('/\s+/','',$html); $html=preg_replace('/[\n\r\t]/','',$html); echo "{$html}"; ?> str_replace("<p><br\/><\/p>","",$htmlstr);Recommended learning: "
PHP Video Tutorial"
The above is the detailed content of How to remove php regular expression br. For more information, please follow other related articles on the PHP Chinese website!