title: PHP - Remove duplicate HTML tags
body: <p>I have a PHP string with an unknown number of <code>br</code> tags. I need to keep only one.</p>
  
  <p><strong>Start string</strong></p>
  
  <pre><code>$str = 'A line of string data&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;with duplicate br tags in here.';
  $str2 = 'Another line with 5 br tags this time.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;New line.';
  $str3 = 'When it&lt;br /&gt;&lt;br&gt;&lt;br /&gt;breaks';
  </code></pre>
  
  <p><strong>Result</strong></p>
  
  <pre><code>$str = 'A line of string data&lt;br&gt;with duplicate br tags in here.';
  $str2 = 'Another line with 5 br tags this time.&lt;br&gt;New line.';
  $str3 = 'When it&lt;br&gt;breaks';
  </code></pre>
  
  <p><strong>My thoughts</strong></p>
  
  <ul>
  <li>First I used <code>str_replace('&lt;br&gt;', '', $str)</code>. It don't go that well because the number of duplicate tags in a row are unknown.</li>
  <li>Some clever regex might solve it? or another solution?</li>
  <li>Would be nice if it would work with or without ending slash. <code>&lt;br&gt;&lt;br /&gt;</code></li>
  </ul>