November 3, 2009

decompress gz with php

Category: PHP, Tags: , , , , khadlock at 9:14 pm

I had a lot of trouble getting zlib to work today with PHP on our Media Temple DV server, but after a lot of testing discovered an easy solution to decompressing/unzipping .gz files.

exec("gunzip Filename.gz", $results);

Once decompressed I can read the file contents using fopen, file_get_contents, etc.

More information on the gzip commands can be found at http://en.wikipedia.org/wiki/Gzip

Bookmark and Share