title: Escaping line break in csv php
body: <p>I have a .csv template I'd wish for people to fill up, save it and upload it.</p>
  
  <p>The problem is this, assuming some users would insert hidden line breaks in a row, when using fgetcsv() it would output the row broken by the hidden line breaks.</p>
  
  <p>How can I escape the line break or sanitize my data?</p>
  
  <p>Possible solution:</p>
  
  <p>assume first row is correct, $count = count the number of delimiters until line break, the rebuild the text into an array as long as $count;</p>
  
  <p>but i think the're better options available.</p>
  
  <p><strong>LATER EDIT</strong></p>
  
  <p>Here's the input *IMPORTANT[ ! ] : the data inside the excel file is "fine", it isn't broken, it's a single row!!! saving it as a csv file and opening it in notepad shows the following</p>
  
  <pre><code>asd;"asd
  asd
  asd";asd;asd
  </code></pre>
  
  <p>Here's the code</p>
  
  <pre><code>$handle = fopen("file.csv","r");
  $data = fgetcsv($handle,";");
  while($data = fgetcsv($handle)) {
      $array = explode(";",$data[0]);
      print_r($array);
  }
  fclose($handle);
  </code></pre>
  
  <p>Here's the echoed data</p>
  
  <pre><code>Array ( [0] =&gt; asd [1] =&gt; "asd ) Array ( [0] =&gt; asd ) Array ( [0] =&gt; asd" [1] =&gt; asd [2] =&gt; asd [3] =&gt; ) 
  </code></pre>
  
  <p>Thanks</p>