Removing newlines in php
<p>Following is the syntax for <code>preg_replace()</code> function in php:</p>

<pre><code>$new_string = preg_replace($pattern_to_match, $replacement_string, $original_string);
</code></pre>

<p>if a text file has both Windows (rn) and Linux(n) End of line (EOL) characters i.e line feeds.</p>

<p>then which of the following is the correct order of applying <code>preg_replace()</code> to get rid of all end of line characters?</p>

<ol>
<li><p>remove cr first</p>

<pre><code>$string = preg_replace('|rn|','',$string);
$string = preg_replace('|n|','',$string);
</code></pre></li>
<li><p>remove plain nl first</p>

<pre><code>$string = preg_replace('|n|','',$string);
$string = preg_replace('|rn|','',$string);
</code></pre></li>
</ol>
