Home >Backend Development >PHP Tutorial >How to read individual files in a zip archive using PHP

How to read individual files in a zip archive using PHP

王林
王林forward
2023-08-26 16:01:121226browse

How to read individual files in a zip archive using PHP

To read a single file in a 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.

The above is the detailed content of How to read individual files in a zip archive using PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete