zip_entry_read() function in PHP


The zip_entry_read() function is used to get the contents from an open zip archive file.

Syntax

zip_entry_read(zip_entry, len)

Parameters

  • zip_entry − The zip entry resource. Required.

  • len − The length in bytes. The default is 1024.

Return

The zip_entry_read() function Returns the contents from an open zip archive file. Returns FALSE on failure.

ExampleThe following is an example. Let’s say our zip file "one.zip" is having only a single file i.e. "detail.txt" with the following content.

Asia is a continent!

Let us see an example −

Example

<?php
   $zip_file = zip_open("one.zip");
   if ($zip_file) {
      while ($zip_entry = zip_read($zip)) {
         if (zip_entry_open($zip_file, $zip_entry)) {
            echo "Text in the file = <br/>";
            echo "zip_entry_read($zip_entry)<br />";
            zip_entry_close($zip_entry);
         }
         echo "</p>";
      }
      zip_close($zip_file);
   }
?>

Output

Text in the file =
Asia is a continent!

Updated on: 27-Dec-2019

34 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements