PHP Tutorial - PHP zip_close() Function






The zip_close() function closes a zip archive opened by the zip_open() function.

Syntax

PHP zip_close() Function has the following syntax.

zip_close(zip)

Parameter

ParameterIs RequiredDescription
zipRequired.Zip resource to close (a zip file opened with zip_open() )

Return

No value is returned.

Example

Close a zip file


<?php
$zip = zip_open("test.zip");
zip_close($zip);
?>




Example 2

The following code shows how to close a zip archive opened by the zip_entry_open() function.


// w  w w.j a  va2 s  .com
<?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)){
             // some code
             zip_entry_close($zip_entry);
         }
         echo "</p>";
      }
      zip_close($zip);
   }
?>