note 32441 added to ref.zlib
| From: | chris at mad-teaparty dot com | Date: | Tue, 27 May 2003 22:10:35 +0000 |
| Subject: | note 32441 added to ref.zlib | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49118@lists.php.net to get a copy of this message | ||
Nice function. I did it the other way round:
function uncompress($srcName, $dstName) {
$zp = gzopen($srcName, "r");
while(!gzeof($zp))
$string .= gzread($zp, 4096);
gzclose($zp);
$fp = fopen($dstName, "w");
fwrite($fp, $string, strlen($string));
fclose($fp);
}
uncompress("./myfile.txt.gz", "./myfile.txt");
A shorter approach would be:
function uncompress($srcName, $dstName) {
$string = implode("", gzfile($srcName));
$fp = fopen($dstName, "w");
fwrite($fp, $string, strlen($string));
fclose($fp);
}
----
Manual Page -- http://www.php.net/manual/en/ref.zlib.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32441
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32441&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32441&report=yes