title: Cleanup HTML with PHP to create clean string
body: <p>I've got a bunch of HTML data that I'm writing to a PDF file using PHP. In the PDF, I want all of the HTML to be stripped and cleaned up. So for instance:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;First list item&lt;/li&gt;
      &lt;li&gt;Second list item which is quite a bit longer&lt;/li&gt;
      &lt;li&gt;List item with apostrophe 's 's&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Should become:</p>
  
  <pre><code>First list item
  Second list item which is quite a bit longer
  List item with apostrophe 's 's
  </code></pre>
  
  <p>However, if I simply use <code>strip_tags()</code>, I get something like this:</p>
  
  <pre><code>   First list item&amp;#8232;
  
     Second list item which is quite a bit
  longer&amp;#8232;
  
     List item with apostrophe &amp;rsquo;s &amp;rsquo;s
  </code></pre>
  
  <p>Also note the indentation of the output. </p>
  
  <p>Any tips on how to properly cleanup the HTML to nice, clean strings without messy whitespace and odd characters?</p>
  
  <p>Thanks :)</p>