Generating comma-separated data
<?php
$sales = array( array('Northeast',12.54),
array('All Regions',1597.34) );
$fh = fopen('sales.csv','w') or die("Can't open sales.csv");
foreach ($sales as $sales_line) {
if (fputcsv($fh, $sales_line) === false) {
die("Can't write CSV line");
}
}
fclose($fh) or die("Can't close sales.csv");
?>
Related examples in the same category