How can I turn this:
...<br />
<br />
...<br />
...<br />
<br />
<br />
...<br />
Into this using PHP:
...<br />
...<br />
...<br />
...
Please notice the deletion of the first and last
even if it’s mentioned once. In the middle we keep just one
This will replace instances of more than one
<br />, optionally with whitespace separating them, with a single<br />.Note that
<br />in the pattern matches exactly that. If you wanted to be more defensive, you could change it to<br[^>]*>which would allow for<br>tags that have attributes (ie.<br style="clear: both;" />) or that don’t have the trailing slash.