Capturing file output in PHP (fputcsv)
<p>I'm attempting to capture the output of <code>fputcsv()</code> in order to use <code>gzwrite()</code> 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 <code>fputcsv()</code> than actually append <code>"\t"</code> and <code>"\n"</code> everywhere.  Can I somehow do this with output buffering or something similar?</p>

<p>Here's the basic outline of what I have:</p>

<pre><code>$results = get_data_from_db();
$fp = gzopen($file_name, 'w');
if($fp) {
    foreach ($results as $row) {
     ???//something with gzwrite() ?
    }
    gzclose($fp);
}
</code></pre>

<p>Thanks!</p>

<p>EDIT: My understanding was that <code>gzwrite()</code> needs to be used to actually write to the file  in order for it to actually be gzipped - is this not correct?</p>
