title: Sanitize (not remove) HTML input for breaking the document, but not other tags
body: <p>Lets assume we have a user form that generates HTML input, and the following could be an example of what gets POSTed to PHP.</p>
  
  <pre><code>&lt;p&gt;Hello&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;World&lt;/strong&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Now, these will show up later on via injected to the HTML output, into some DIV.</p>
  
  <p>What I'd like to prevent is the following being entered in:</p>
  
  <pre><code>&lt;/div&gt;
  &lt;p&gt;Hello&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;World&lt;/strong&gt;&lt;/p&gt;
  &lt;div&gt;
  </code></pre>
  
  <p>Or even something like:</p>
  
  <pre><code>&lt;/div&gt;
  &lt;script&gt; someScript(); &lt;/script&gt;
  &lt;iframe src="http://www.example.com"&gt;......
  &lt;p&gt;Hello&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;World&lt;/strong&gt;&lt;/p&gt;
  &lt;div&gt;
  </code></pre>
  
  <p>How can I use PHP to determine that this input will not break the document, include bad iframes, or run scripts? The most importat part is I still want that information, I'm not throwing it out, but it needs to be included as harmless text of some sort.</p>
  
  <p>Using alternative markup is not an option, it needs to be HTML.</p>