Printing comma-separated data : CSV File « File Directory « PHP






Printing comma-separated data

 
<?php

$sales = array( array('Northeast',12.54),
                array('All Regions',12.34) );

$fh = fopen('php://output','w');
foreach ($sales as $sales_line) {
    if (fputcsv($fh, $sales_line) === false) {

        die("Can't write CSV line");
    }
}
fclose($fh);
?>
  
  








Related examples in the same category

1.Generating comma-separated data
2.Making a CSV-formatted string
3.Parsing CSV Strings
4.Read csv file
5.Reading CSV data from a file
6.Tell the web client to view the CSV file in a seprate program
7.fgetcsv.php
8.Putting comma-separated data into a string