title: Write to CSV with PHP function fputcsv
body: <p>I am using <code>fputcsv</code> to write to a CSV from MySQL results:</p>
  <pre><code>$list = array(&quot;group, variable, value \r\n&quot;);
  
  while ($row = mysqli_fetch_assoc($result)) {
    array_push($list, $row['strand_pk'] . ',' . $row['unit_name']. &quot;\r\n&quot;);
  }
  
  $fp = fopen('../reports/data.csv', 'w');
  
  fputcsv($fp, $list);
  
  fclose($fp);
  </code></pre>
  <p>The array when printed on the browser page looks like:</p>
  <pre><code>Array
  (
      [0] =&gt; group, variable, value 
  
      [1] =&gt; 1,Integrated Medical Systems 1
  
      [2] =&gt; 1,Integrated Medical Systems 2
  
      [3] =&gt; 1,Integrated Medical Practice 1
      
      ...
  )
  </code></pre>
  <p>The CSV with output looks like:</p>
  <pre><code>&quot;group, variable, value 
  &quot;,&quot;1,Integrated Medical Systems 1
  &quot;,&quot;1,Integrated Medical Systems 2
  &quot;,&quot;1,Integrated Medical Practice 1
  ...&quot;
  </code></pre>
  <p>What I need is the CSV to look like:</p>
  <pre><code>group,variable,value
  1,IMP 3,40
  1,IMP 2,8
  1,IMP 1,54
  1,IMS 2,10
  </code></pre>
  <p>What am I doing wrong here?</p>