我在 PHP 中看到了 ZipArchive 类,它可以让您读取 zip 文件。但我想知道是否有一种方法可以在不先提取文件的情况下迭代其内容
最佳答案
在 http://www.php.net/ziparchive 上的评论中找到:
The following code can be used to get a list of all the file names in a zip file.
<?php $za = new ZipArchive(); $za->open('theZip.zip'); for( $i = 0; $i < $za->numFiles; $i++ ){ $stat = $za->statIndex( $i ); print_r( basename( $stat['name'] ) . PHP_EOL ); } ?>
关于php - 在 PHP 中是否可以在不首先提取其内容的情况下检查 Zip 文件的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9817525/