PHP zip_entry_read() function

Definition and Usage

zip_entry_read() function retrieves the content from the opened zip archive project.

If successful, it returns the content of the item. If it fails, it returns false.

Syntax

zip_entry_read(zip_entry,length)
Parameter Description
zip_entry Required. Specifies the zip project resource to be read (opened by zip_read()).
length Optional. Specifies the number of bytes to return. The default is 1024.

Example

<?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);
}
?>