Replace Multiple break line to single break line using php
by satheeshkumar[ Edit ] 2014-06-05 16:44:18
Replace Multiple <br> to single <br> using preg replace in php,
preg_replace('#(<br */?>s*)+#i', '<br />', $htmlcontent);
Example :
<?php
$html ="HTML<br><br /><br>
PHP<br><br /><br><br /><br><br><br /><br><br><br /><br>
Languages<br><br /><br /><br>";
$html = preg_replace('#(<br */?>s*)+#i', '<br />', $html);
echo $html;
?>
In the above example it results contents with single break line.