How to read a single file inside a zip archive with PHP


To read a single fine inside z zip archive, the code is as follows −

$handle = fopen('zip://test.zip#test.txt', 'r');
$result = '';
while (!feof($handle)) {
   $result .= fread($handle, 8192);
}
fclose($handle);
echo $result;

The output will be the contents of the zip file.

Updated on: 07-Apr-2020

751 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements