Re: Sending output to the browser

From: Date: Sun, 22 Jan 2006 11:23:44 +0000
Subject: Re: Sending output to the browser
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22638@lists.php.net to get a copy of this message
On Saturday 21 January 2006 14:25, Ed Greenberg wrote: > 1. Is there anything in pear that can help build csv output from DB output, > or should I just do it with print statements. fputcsv() is an easy option, something like.. <?php $fp = fopen('php://output', 'w'); while ($row = mysql_fetch_row($res)) { fputcsv($fp, $row); } fclose($fp); ?> It's new to PHP 5.1 but it's implemented in PEAR::PHP_Compat for earlier versions. > 2. Is there anything in pear that would zip the output up on the way to the > browser so I don't have to get involved with cleaning up temporary files. HTTP_Download does this nicely as already suggested, but it makes the CSV bit slightly trickier. Using ob_start() and ob_get_clean() to capture the output of fputcsv() is probably easiest and fastest, you could also adapt the PHP_Compat implementation or of course roll your own to build a string directly.

« previous php.pear.general (#22638) next »