php.net/fputcsv
<?php
$file = "file.csv";
$list = array(
array('John A. Smith' , 'San Francisco', 19),
array('Bob I. Uncle' , 'Los Angele' , '789'),
array('"Joan K. Jones"', '"New York"')
);
$fp = fopen($file, 'w');
foreach ($list as $row) {
fputcsv($fp, $row);
}
fclose($fp);
echo '<pre>'; var_dump($list);
?>
<?php
$file = "file.csv";
$list = array();
if (($fp = fopen($file, "r")) !== false) {
while (($row = fgetcsv($fp, 1000, ",")) !== false) {
$list[] = $row;
}
fclose($fp);
}
echo '<pre>'; var_dump($list);
?>