🤖🚫 AI-free content. This post is 100% written by a human, as is everything on my blog. Enjoy!

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

June 12, 2009 , revised January 9, 2011 in 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 Понравился пост? Купи мне кофе