title: Replace any combination of (CR) and (LF) with a single (CRLF) in a text file using php
body: <p>In different text files (or also inside single text file) I have different end-of-lines combinations (see example below).</p>
  
  <p>How to uniform all combinations of CR and LF with one simple CRLF?
  In a few words I need to replace every CR and LF combinations with one single CRLF using PHP.
  With str_replace I can replace them but my issue is the right search string to use.</p>
  
  <pre><code>$textfile=str_replace("search string i need","CRLF to replace", $textfile);
  </code></pre>
  
  <p>Example of a generic text file to fix:</p>
  
  <pre><code>text line 1 CRLFLFCRCRLF
  text line 2 LFLFCRLFCRCR
  text line 3 CRLF
  text line 4 CR
  text line 5 LF
  </code></pre>
  
  <p>I need to replace all the \r \n random combinations with only \r\n like this:</p>
  
  <pre><code>text line 1 CRLF
  text line 2 CRLF
  text line 3 CRLF
  text line 4 CRLF
  text line 5 CRLF
  </code></pre>