title: how to remove new lines and returns from php string?
body: <p>A php variable contains the following string:</p>
  
  <pre><code>&lt;p&gt;text&lt;/p&gt;
  &lt;p&gt;text2&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;item1&lt;/li&gt;
  &lt;li&gt;item2&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I want to remove all the new line characters in this string so the string will look like this:</p>
  
  <pre><code>&lt;p&gt;text&lt;/p&gt;&lt;p&gt;text2&gt;&lt;ul&gt;&lt;li&gt;item1&lt;/li&gt;&lt;li&gt;item2&lt;/li&gt;&lt;/ul&gt;
  </code></pre>
  
  <p>I've tried the following without success:</p>
  
  <pre><code>str_replace('\n', '', $str);
  str_replace('\r', '', $str);
  str_replace('\r\n\', '', $str);
  </code></pre>
  
  <p>Anyone knows how to fix this?</p>