Compresses and decompresses Zlib- or GZIP-encoded data stream (RFC 1950/1952).
GZIP compression is a widely used method of compressing web pages and other text data – sometimes it can reduce the size of source document by 70-80% at the same time requiring little CPU processing.
On this page you can encode or decode GZ data online. You can do so by direct imput, by file upload or by URL. Also, different variants of GZ compression are supported:
As explained in this article, PHP has gzencode function to encode GZIP data but no gzdecode counterpart. However, it can be rewritten using readgzfile that will work in PHP 4+.
// taken from http://proger.i-forge.net/gzdecode_doesnt_work_in_PHP_pre-6/OQB
function gzdecode($data) {
do {
$tempName = uniqid('temp ');
} while (file_exists($tempName));
if (file_put_contents($tempName, $data)) {
try {
ob_start();
@readgzfile($tempName);
$uncompressed = ob_get_clean();
} catch (Exception $e) {
$ex = $e;
}
unlink($tempName);
if (isset($ex)) {
throw $ex;
}
return $uncompressed;
}
}