title: How to replace different newline styles in PHP the smartest way?
body: <p>I have a text which might have different newline styles.
  I want to replace all newlines '\r\n', '\n','\r' with the same newline (in this case \r\n ).</p>
  
  <p>What's the fastest way to do this? My current solution looks like this which is way sucky:</p>
  
  <pre><code>    $sNicetext = str_replace("\r\n",'%%%%somthing%%%%', $sNicetext);
      $sNicetext = str_replace(array("\r","\n"),array("\r\n","\r\n"), $sNicetext);
      $sNicetext = str_replace('%%%%somthing%%%%',"\r\n", $sNicetext);
  </code></pre>
  
  <p>Problem is that you can't do this with one replace because the \r\n will be duplicated to \r\n\r\n .</p>
  
  <p>Thank you for your help!</p>