1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php // output up to 5MB is kept in memory, if it becomes bigger // it will automatically be written to a temporary file $csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+'); fputcsv($csv, array('blah','blah')); rewind($csv); //resets the file pointer to the beginning of the file // put it all in a variable $output = stream_get_contents($csv); echo $output; ?> |
And add a heading
1 2 3 4 |
$heading = array("xxxxxxxx", "xxxxxxxx", "xxxxxxxx", "xxxxxxxx","etc"); fputcsv($csv, $heading); |