Ive looked around and ive found similar examples and gave them a shot but I can't get mine to work...
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 )
<?php
error_reporting(-1);
$list = array (
$_POST['names'],
$_POST['numbers']
);
$fp = fopen('numbers.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
The below works...
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('"aaa"', '"bbb"')
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
here is the more new version, somewhat working but not quite...
<?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);
?>
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...
|"john Hartz" "Cindy Cinamon" "Fruit Cake"|
---------------------------------------
| 905855369941676413454167641543 |