Get the contents from a open zip archive entry in PHP

Description

The following code shows how to get the contents from a open zip archive entry.

Example


//from w w w .  j  a va 2s . c  o m
<?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);
    }
?>




















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip