Posted By

cerxx on 09/04/19


Tagged

php-hacks


Versions (?)

How do I remove extra br tags from HTML using PHP


 / Published in: PHP
 

URL: http://qaru.site/questions/1355901/how-to-remove-redundant-br-tags-from-html-code-using-php#4265240

How do I remove extra <br/"> tags from HTML using PHP?

  1. function clean($txt){
  2. $txt=preg_replace("{(<br[\\s]*(>|\/>)\s*){2,}}i", "<br /><br />", $txt);
  3. $txt=preg_replace("{(<br[\\s]*(>|\/>)\s*)}i", "<br />", $txt);
  4. return $txt;
  5. }

Report this snippet  

You need to login to post a comment.