You can do this with a regular expression:
preg_replace("/(<br\s*\/?>\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.
More Related Contents:
- Turn Plain Text URLs into Active Links using PHP [closed]
- How to extract img src, title and alt from html using php? [duplicate]
- Extract URLs from text in PHP
- How to replace text URLs and exclude URLs in HTML tags?
- PHP Regular expression to match keyword outside HTML tag
- Strip all HTML tags, except allowed
- RegExp to strip HTML comments
- Need a good regex to convert URLs to links but leave existing links alone
- How to get Open Graph Protocol of a webpage by php?
- Count all HTML tags in page PHP
- Regex matching table rows in HTML [duplicate]
- Regex ignore URL already in HTML tags
- PHP/regex: How to get the string value of HTML tag?
- Submit a form using Shift + Enter [duplicate]
- Date format using dd/mm/yyyy using HTML
- Php condition doesn't work for html [closed]
- Display in stock data in short description [closed]
- Divide php echo rows into 3 columns
- How to insert images into a database using PHP [closed]
- How Can I add HTML And CSS Into PDF [closed]
- How do you parse and process HTML/XML in PHP?
- How to display HTML tags as plain text [duplicate]
- How to parse HTML in PHP?
- mysql_fetch_array() expects parameter 1 to be resource problem [duplicate]
- PHP Undefined Index [duplicate]
- prevent direct url access to php file
- How do I return a proper success/error message for JQuery .ajax() using PHP?
- Remove accents without using iconv
- Regex to match an IP address [closed]
- Escape HTML to PHP or Use Echo? Which is better?