title: Carriage return and line feed
body: <p>I got stuck with carriage return and line feed problem. When I run my script it shows CR,LF inside double quote of last field and there is another LF after than, realistically CR,LF should be outside of double quote of text and there shouldn't be another LF. Can somebody tell me what am I doing wrong?</p>
  
  <p>Here is my code</p>
  
  <pre><code>$jobno = 5285;
  
  $directory = "../CSV/";
  $filename = $jobno.'.csv';
  if( is_dir($directory) === false )
  {
     mkdir($directory); // Create new directory 
  
  }
  $newFname = $directory.$filename;
  
  $file = fopen($newFname, 'w');
  
  
  $jobdetails="2,000 Items Supplied";
  $customerName="Snap Pitzaa Ltd";
  $workflow="CSV_wise";
  $jobqty=50;
  $filepath="Data/Snap Pitzaa/design.pdf \r\n";
  
  $data = array(
      array($jobno, $jobdetails, $customerName, $workflow, $jobqty, $filepath),
      array('Data 21', 'Data 22', 'Data 23', 'Data 24', 'Data 25', 'Data 26'),
  
  );
  
  // save each row of the data
  foreach ($data as $row)
  {
      fputcsv($file, $row);
  }
  
  // Close the file
  fclose($file);
  </code></pre>
  
  <p>I've tried all the things like single quote, outside doubleheader of <code>$filepath</code> but none of this is working. Here is output in notepad++</p>
  
  <p><a href="https://i.stack.imgur.com/b7GwM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b7GwM.jpg" alt="enter image description here"></a></p>