我需要读取 zip 文件内的单个文件“test.txt”的内容。整个 zip 文件是一个非常大的文件(2GB)并且包含很多文件(10,000,000),因此提取整个文件对我来说不是一个可行的解决方案。如何读取单个文件?
尝试使用zip:// wrapper:
$handle = fopen('zip://test.zip#test.txt', 'r');
$result = '';
while (!feof($handle)) {
$result .= fread($handle, 8192);
}
fclose($handle);
echo $result;
您可以使用file_get_contents too:
$result = file_get_contents('zip://test.zip#test.txt');
echo $result;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)