Определить и распаковать gzip

June 12, 2009, revised January 9, 2011 gzip PHP
function gzip_decode($string)
{
  if (substr($string,0,2) == "\x1f\x8b") {
    //gzuncompress isn't working properly, so...
    $t = tempnam();
    file_put_contents($t,$data);
    $gzip = trim(`which gzip`);
    $string = `$gzip -cd $t`;
    unlink($t);
  }
  return string;
}

Buy Me a Coffee at ko-fi.com