Read a zip file.

zip_entry_read() example

 
 

Share on Google+Share on Google+

Read a zip file.

Ads

zip_entry_read() example

zip_entry_read()

In this example the function zip_entry_read() will help in reading a zip file. First select a file to be opened. Name that file into zip file and direct the zipread command to read it through while loop. The zip_entry_read command will read one byte at a time. when it reads all the contents, it will executed and file will be closed. 

<?php
$zipname = zip_open("new1.zip");
if ($zipname){ 
while($zipcontent = zip_read($zipname)){
echo zip_entry_name($zipcontent);
if (zip_entry_open($zipname, $zipcontent)){ 
$content = zip_entry_read($zipcontent,1024);
echo "Contents : ".$content;
zip_entry_close($zipcontent);
}
}
}
zip_close($zipname);
?>

Advertisements

Posted on: July 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles