Multiple <br /><br><br/>\r\n occurences needs to be replaced with <br />
<p>I need to replace multiple occurences of <code>&lt;br /&gt;</code>, <code>&lt;br&gt;</code>, <code>&lt;br/&gt;</code>, <code>\r</code>, <code>\n</code>, <code>\r\n</code> with only 1 <code>&lt;br /&gt;</code>, but only where it shows up together so that I can split paragraphs into an array and trim out the last line break of <code>br</code> tag at the end of the string...</p>

<p>An Example of a string could be as follows:</p>

<pre><code>This is paragraph 1&lt;br&gt;

This is paragraph 2&lt;br /&gt;&lt;br&gt;



This is paragraph 3
This is paragraph 4


This is paragraph 5&lt;br/&gt;
This is paragraph 6


This is paragraph 7&lt;br /&gt;This is paragraph 8

This is paragraph 9&lt;br&gt;
</code></pre>

<p>What I've tried:</p>

<pre><code>$description = !empty($results['Description']) ? strip_tags(rtrim(str_replace(array("\n", "\r", "\r\n", "&lt;br&gt;", "&lt;br/&gt;", "&lt;br /&gt;"), array("&lt;br /&gt;"), $results['Description']), '&lt;br /&gt;'), '&lt;br&gt;&lt;a&gt;') : '';

$paragraphs = array_filter(explode("&lt;br /&gt;", $description));
</code></pre>

<p>But this trims out all line breaks.  I need to maintain line breaks where they are in the string, but only want to do 1 linebreak and remove all others.  How to do this?</p>

<p>Note:  I am using strip_tags because I want to only allow <code>&lt;br&gt;</code> and <code>&lt;a&gt;</code> tags in the <code>$description</code> string.</p>