How can I unzip a .gz file with PHP?

Viewed 26291

I'm using CodeIgniter and I can't figure out how to unzip files!

5 Answers

gzopen is way too much work. This is more intuitive:

$zipped = file_get_contents("foo.gz");
$unzipped = gzdecode($zipped);

works on http pages when the server is spitting out gzipped data also.

If you have access to system():

system("gunzip file.sql.gz");
Related