title: php writing to csv from an array
body: <p>Ive looked around and ive found similar examples and gave them a shot but I can't get mine to work...</p>
  
  <p>Here is mine...It doesnt work..What am I doing wrong :S?
  The type of POST is arrays so I guess I have to convert it to string to make it work..
  The names and numbers look like this:
  Array ( [0] => john Hartz [1] => Cindy Cinamon [2] => Fruit Cake ) Array ( [0] => 9058553699 [1] => 4167641345 [2] => 4167641543 ) </p>
  
  <pre><code>&lt;?php
  error_reporting(-1);
  
  
  $list = array (
      $_POST['names'],
      $_POST['numbers']
  );
  
  $fp = fopen('numbers.csv', 'w');
  
  foreach ($list as $fields) {
      fputcsv($fp, $fields);
  }
  
  fclose($fp);
  ?&gt;
  </code></pre>
  
  <p>The below works...
      
  
  <pre><code>$list = array (
      array('aaa', 'bbb', 'ccc', 'dddd'),
      array('"aaa"', '"bbb"')
  );
  
  $fp = fopen('file.csv', 'w');
  
  foreach ($list as $fields) {
      fputcsv($fp, $fields);
  }
  
  fclose($fp);
  ?&gt;
  </code></pre>
  
  <p>here is the more new version, somewhat working but not quite...</p>
  
  <pre><code>&lt;?php
  error_reporting(-1);
  
  
  $name = implode(",", $_POST['names']);
  $num= implode(",", $_POST['numbers']);
  $list = array (
      array($name, $num)
  );
  
  $fp = fopen('numbers.csv', 'w');
  
  foreach ($list as $fields) {
      fputcsv($fp, $fields);
  }
  
  fclose($fp);
  ?&gt;
  </code></pre>
  
  <p>brady, the problem isnt formatting....You see where you have "|" between names or numbers.... that im guessing shows the border between 1 cell and the other....well what I am getting is an ENTIRE array into ONE cell...So something like this...</p>
  
  <pre><code>|"john Hartz"  "Cindy Cinamon" "Fruit Cake"|
  
  ---------------------------------------
  
  | 905855369941676413454167641543 |
  </code></pre>