title: Generate pipe delimited file through php
body: <p>My code generates a txt file using PHP's fputcsv function.</p>
  
  <p>For the delimiter, I am trying to use '|' </p>
  
  <pre><code>$query = mysql_query("SELECT email, emailSource FROM session WHERE is_complete='1' ORDER by sessionid ASC")
  
  $filename= 'here.txt';
  
  $fp = fopen( $filename,'w');
  
  
  fputcsv($fp, array('Email address', 'Email Source'));
  
  if(mysql_numrows($query) &gt; 0) {
  
      while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
              fputcsv($fp, array_values($row));
      }
  }
  
  
  fclose($fp);
  $contents = file_get_contents($filename);
  $contents = str_replace(",", "|", $contents);
  file_put_contents($filename, $contents);
  </code></pre>
  
  <p>The result I get is all on one line instead of showing the values on a seperate line and I also have "" around the headers.</p>
  
  <pre><code>"Email address"|"Email Source"|blah@blah.com|hi|
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>Email address|Email Source|
  
  blah@blah.com|hi|
  </code></pre>
  
  <p>Please can someone tell me what I am doing wrong. Is it because I am using fputcsv and saving to a txt file?</p>