PHP
PHP
Ungzip Base64 String
See more Gzip Examples
Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.Chilkat PHP Downloads
<?php
use Chilkat2\BinData;
use Chilkat2\Gzip;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$gzip = new Gzip();
$gzipBase64 = 'H4sIAAAAAAAE ... X6aZjXO3EwAA';
$bd = new BinData();
$bd->AppendEncoded($gzipBase64, 'base64');
try {
$gzip->UncompressBd($bd);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
$strXml = $bd->GetString('utf-8');
echo "XML:\n";
echo $strXml, "\n";