Home >Backend Development >PHP Tutorial >Example of how to read zip files in PHP
The example in this article describes how to read zip files with PHP. Share it with everyone for your reference, the details are as follows:
<?php $zip = zip_open("111.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { echo "Name: " . zip_entry_name($zip_entry) . "n"; echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "n"; echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "n"; echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "n"; if (zip_entry_open($zip, $zip_entry, "r")) { echo "File Contents:n"; $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); echo "$buf\n"; zip_entry_close($zip_entry); } echo "n"; } zip_close($zip); } ?>
The screenshot of the running effect is as follows:
The above is the content of the example of how to read zip files in PHP. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!