I need to be able to decompress through PHP some data that I have in a string which uses the gzip
format. I need to do this via PHP, not by calling - through system
for example - an external program.
I go to the documentation and I find gzdecode. Too bad it doesn't exist. Digging further through google it appears this function was implemented in PHP6, which I cannot use. (Interestingly enough gzencode
exists and is working).
I believe - but I'm not sure - that the gzip
format simply has some extra header data. Is there a way to uncompress it by manipulating this extra data and then using gzuncompress
, or some other way?
Thanks
Try gzinflate.
Well I found my answer by reading the comments on the
gzdecode
page I linked in my original post. One of the users, Aaron G, provided an implementation of it and it works:Did you tried
gzuncompress
? http://www.php.net/manual/en/function.gzuncompress.phpgzdecode()
is not yet in PHP. But you can use the implementation from upgradephp. It really is just a few extra header bytes.Another option would be to use gzopen. Maybe just like
gzopen("data:app/bin,....")
even.