Fri, 17 May 2024


How to open a zip file and read its contents?

By: Peter, NetArt Media
Wed, 16 June 2021

resource zip_open ( string filename)

The idea of the zip_open() function is to load in a zip file and interate through its contents

<?php

$zp = zip_open("/myfiles/blah.zip");

while($zipFile = zip_read($zip))
{
echo "Filename: " . zip_entry_name($zipFile) . "<br>";
echo "Compressed Size: " . zip_entry_compresedsize($zipFile) . "<br>";
echo "Real Size: " . zip_entry_filesize($zilFile) . "<br><br>";
}

?>


(You must have the ZZIPlib library installed along with PHP before zip_open() will work.)


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox