title: Handling new lines in php
body: <p>I have form in html where user can put the text in text area. <br />
  I save the content of text area into MySQL database (in field of type TEXT). <br />
  Then I somewhere in my aplication I need load that text and put it into array where in each index will be one line of the text.</p>
  
  <pre><code>&lt;textarea rows="10" cols="80"&gt;
  Row one
  Row two
  Row tree
  &lt;/textarea&gt;
  
  array (output in "php pseudocode"):
  $array = array();
  $array[0] = Row one;
  $array[1] = Row two;
  $array[2] = Row tree;
  </code></pre>
  
  <p>How I do it:
  I save it to db then I load it and use: </p>
  
  <pre><code>$br = nl2br($string,true);
  $array = explode("&lt;br /&gt;", $br);
  </code></pre>
  
  <p>The reason why I use <strong>nl2br</strong> is I want to avoid problems with end of lines of the text from different platforms. I mean /n or /r/n. <br />
  But in my solution must be an error somewhere cause it doesn't work (an array $array is empty).<br />
  <br />
  Better solution would be probably somehow split it into array using explode or something like that with pattern for line breaks but here is again the problem from beginning with line breaks which I don't know how to solve (<strong>problems with \n or \r\n</strong>).<br />
  <br />
  Can anybody give me an advice? Thanks. <br /></p>