I'm outputting a large csv file through standard output (php://output) by using the built-in fputcsv function, but I get a memory error after writing about 14000 lines.
I called ob_end_clean to not use the output buffer, but it doesn't work. Also, I tried flushing the output buffer after every X lines, but it's the same.
Here's a snippet of my code:
function outputCSV($data) {
ob_end_clean(); //Delete buffer contents and disable output buffering
$outstream = fopen("php://output", "w");
function __outputCSV(&$vals, $key, $filehandler) {
fputcsv($filehandler, $vals);
}
array_walk($data, "__outputCSV", $outstream);
fclose($outstream);
}