title: php replace \n except where other valid HTML tags appear
body: <p>I am looking for a function that replaces \n stored in the db via user input into a textfield, except where there are already HTML tags in place. This is for a CMS, so that the dumbass users have less work to do. </p>
  
  <p>So, for-instance, if the user wrote the following into the textfield:</p>
  
  <pre><code>&lt;H1&gt;Title of page&lt;/H1&gt;
  
  This is the first paragraph in the page.
  
  &lt;H2&gt;Sub section&lt;/H2&gt;
  
  This is a sub-section.
  </code></pre>
  
  <p>I'd want the function to return:</p>
  
  <pre><code>&lt;H1&gt;Title of page&lt;/H1&gt;
  
  &lt;p&gt;This is the first paragraph in the page.&lt;/p&gt;
  
  &lt;H2&gt;Sub section&lt;/H2&gt;
  
  &lt;p&gt;This is a sub-section.&lt;/p&gt;
  </code></pre>
  
  <p>Can anyone help with something they already have / have found?</p>