I'm attempting to capture the output of fputcsv()
in order to use gzwrite()
to actually write to a tab-delimited file. Basically, I'm querying a database and I want to put these rows into a gzipped CSV file and I'd rather use fputcsv()
than actually append "\t"
and "\n"
everywhere. Can I somehow do this with output buffering or something similar?
Here's the basic outline of what I have:
$results = get_data_from_db();
$fp = gzopen($file_name, 'w');
if($fp) {
foreach ($results as $row) {
???//something with gzwrite() ?
}
gzclose($fp);
}
Thanks!
EDIT: My understanding was that gzwrite()
needs to be used to actually write to the file in order for it to actually be gzipped - is this not correct?