title: php array to csv conversion with column headers
body: <p>I want to convert array to csv ,im able to convert the associative array to csv.</p>
  
  <p>But not able to get the headers.</p>
  
  <p>I want the NUMBER TYPE DATE as headers dynamically</p>
  
  <p>Below is the array i converrted .</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [NUMBER] =&gt; 67
              [TYPE] =&gt; Other
              [DATE] =&gt; 3/31/2011
          )
       [1] =&gt; Array
            (
              [NUMBER] =&gt; 87
              [TYPE] =&gt; something
              [DATE] =&gt; 3/28/2011
  
  
            )
       [2] =&gt; Array
            (
              [NUMBER] =&gt; 67
              [TYPE] =&gt; Other
              [DATE] =&gt; 3/2/2011
  
  
            )
  
  )
  </code></pre>
  
  <p>The code is given below .But not able to get the headers but its values are coming.</p>
  
  <pre><code>&lt;?
   $fp1 = fopen('file.csv', 'w');
  
  foreach ($arr2 as $fields) 
  {
      fputcsv($fp1, $fields);
  }
  
  fclose($fp1);
  ?&gt;
  </code></pre>