title: Remove empty HTML from a document
body: <p>I need some help stripping empty tags in my HTML. There is a solution here:</p>
  
  <p><a href="https://stackoverflow.com/questions/3129738/remove-empty-tags-using-regex">Remove empty tags using RegEx</a></p>
  
  <p>But I can't use JS, <a href="https://stackoverflow.com/a/1732454/257493"><strong>and I should never use Regular expressions to parse HTML</strong></a>.</p>
  
  <p>I need to clean inputs with PHP, and I also need to get more than just empty tags.</p>
  
  <p>I also need to catch tags like this:</p>
  
  <pre><code>&lt;p&gt; &lt;/p&gt; (variable whitespace with nothing in the tag)
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;p&gt;&lt;br/&gt;&lt;p&gt;
  &lt;p&gt;&lt;br /&gt;&lt;/p&gt;
  </code></pre>
  
  <p>What can I do to catch bad markup like that before it makes it to the database (WYSIWYGs)?</p>