Wanted to convert
<br/> <br/> <br/> <br/> <br/>
into
<br/>
You can do this with a regular expression:
preg_replace("/(<brs*/?>s*)+/", "<br/>", $input);
This if you pass in your source HTML, this will return a string with a single <br/> replacing every run of them.
2.1m questions
2.1m answers
60 comments
57.0k users