When writing .csv files i use fputcsv like this:
- open a temporary file $f = tmpfile(); - write content to file using fputcsv($f,$csv_row); - send appropriate headers for attachment - read file like this: # move pointer back to beginning rewind($f); while(!feof($f)) echo fgets($f); # fclose deletes temp file ! fclose($f);
Another aproach would be:
- open file $f = fopen('php://output', 'w'); - send appropriate headers for attachment - write content to file using fputcsv($f,$csv_row); - close $f stream
My question is: What would be the best approach to output the data faster and taking into account server resources ?
First method would use more writes and consume more resources but would output very fast.
Second method uses less writes and would output slower i think.
Eagerly waiting for your opinions on this.
Thanks.