title: remove white space inside tags without removing \n
body: <p>How to remove white spaces inside all tags, but, and this is important, <strong>without removing \n</strong></p>
  
  <p>In this example I have two type of tags. I am looking for something that could work in any text with any type of tags.</p>
  
  <p>I have this:</p>
  
  <pre><code>$text ="&lt;p&gt; some text &lt;/p&gt;&lt;h2&gt; some text&lt;/h2&gt;\n
  &lt;p&gt;some text &lt;/p&gt;&lt;h2&gt;some text &lt;/h2&gt;";
  </code></pre>
  
  <p>I want this:</p>
  
  <pre><code>&lt;p&gt;some text&lt;/p&gt;&lt;h2&gt;some text&lt;/h2&gt;\n 
  &lt;p&gt;some text&lt;/p&gt;&lt;h2&gt;some text&lt;/h2&gt;
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>$text = preg_replace ("/&gt;\s+/", "&gt;", $text);//remove space from start
  $text = preg_replace ("/\s+&lt;/", "&lt;", $text);//and end
  echo $text;
  </code></pre>
  
  <p>The problem is that, it removes the \n too.</p>