title: PHP end of line character for a csv file
body: <p>What is the right way to specify the end of line character of a CSV file with PHP.  I have this script to write the CSV file. </p>
  
  <pre><code>&lt;?php
  
  ini_set('display_errors', 1);
  error_reporting(E_ALL);
  
  include_once("phpshared.php");
  
  function get_node_urls( $nodeid ) {
  
  $nodes = new SimpleXMLElement('linkcards.xml', null, true);
  $nodesarray = $nodes-&gt;xpath("//LINKCARD[@ID='$nodeid']");  
  
  $linkstring = '';
  $node = $nodesarray[0]; 
  $i = 0;
  foreach($node-&gt;LINKS-&gt;LINK as $url)
  { 
         $linkstring .= $i.','.$url['ID'].','.$url-&gt;TITLE.','.$url-&gt;URL.'\r\n';
         $i++;
  }
  echo $linkstring;
  
  }
  
  echo get_node_urls(trim($_REQUEST['nodeid']));
  
  ?&gt;
  </code></pre>
  
  <p>If I load <code>$linkstring</code> there is no carriage return at the end of each line.  The lines should be:</p>
  
  <pre>
  0, id1, http://link1.com
  1, id2, http://link2.com
  </pre>
  
  <p>Instead they are:</p>
  
  <pre>
  0, id1, http://link1.com\r\n1, id2, http://link2.com
  </pre>
  
  <p>The CSV reader reads that line as:</p>
  
  <pre>
  id1 http://link1.com\r\n1
  </pre>
  
  <p>Is there a different way of writing the end of line for a CSV?</p>