Putting comma-separated data into a string : CSV File « File Directory « PHP






Putting comma-separated data into a string

 
<?php

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

ob_start();
$fh = fopen('php://output','w') or die("Can't open php://output");
foreach ($sales as $sales_line) {
    if (fputcsv($fh, $sales_line) ===  false) {

        die("Can't write CSV line");
    }
}
fclose($fh) or die("Can't close php://output");
$output = ob_get_contents();
ob_end_clean();
?>
  
  








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.Printing comma-separated data