note 38886 deleted from function.gzfile by nlopess

From: Date: Sat, 10 Jan 2004 09:52:58 +0000
Subject: note 38886 deleted from function.gzfile by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63240@lists.php.net to get a copy of this message
Note Submitter: webmaster@ragnarokonline.de ---- For those who search for a function similar to file_get_contents but for gzip-files, here is one ;) This is actually a port of the code-snippet I've posted at http://www.php.net/file_get_contents Note: filesize can't be used here, because the length-paramenter of gzread is used for the uncompressed and not for the compressed content. <?php if (!function_exists('gzfile_get_contents')) { function gzfile_get_contents($filename, $use_include_path = 0) { $file = @gzopen($filename, 'rb', $use_include_path); if ($file) { $data = ''; // just to be safe. Dunno, if this is really needed while (!gzeof($file)) $data .= gzread($file, 1024); gzclose($file); } return $data; } } ?>

« previous php.notes (#63240) next »