The zip_entry_read() function retrieves the contents from an open zip archive.
If successful, the function returns the contents of the item. If it fails, returns FALSE.
zip_entry_read(zip_entry,length)
parameter | describe |
---|---|
zip_entry | Required. Specifies the zip project resource to be read (the zip project opened by zip_read()). |
length | Optional. Specifies the number of bytes (uncompressed size) to be returned. The default is 1024. |
<?php$zip = zip_open("test.zip");if ($zip) { while ($zip_entry = zip_read($zip)) { echo "<p>"; echo "Name: " . zip_entry_name($zip_entry ) . "<br />"; if (zip_entry_open($zip, $zip_entry)) { echo "File Contents:<br/>"; $contents = zip_entry_read($zip_entry); echo "$contents<br />"; zip_entry_close($zip_entry); } echo "</p>"; }zip_close($zip);}?>
The output of the code depends on the contents of the zip archive:
Name: ziptest.txtFile Contents:Hello World! This is a test for a the zip functions in PHP. Name: htmlziptest.htmlFile Contents: Hello World! This is a test for a the zip functions in PHP.