Need PHP script to decompress and loop through zipped file.

Posted by Jim H. on Stack Overflow See other posts from Stack Overflow or by Jim H.
Published on 2010-04-08T13:20:52Z Indexed on 2010/04/08 13:23 UTC
Read the original article Hit count: 435

Filed under:
|
|

I am using a fairly straight-forward script to open and parse several xml files that are gzipped. I also need to do the same basic operation with a ZIP file. It seems like it should be simple, but I haven't been able to find what looked like equivalent code anywhere.

Here is the simple version of what I am already doing:

$import_file = "source.gz";

$sfp = gzopen($import_file, "rb");  /////  OPEN GZIPPED data
while ($string = gzread($sfp, 4096)) {    //Loop through the data

    /// Parse Output And Do Stuff with $string
}
gzclose($sfp);      

What would do the same thing for a zipped file?

© Stack Overflow or respective owner

Related posts about php

Related posts about zip