我正在使用ZipArchive
类来解压缩文件并将其内容放在有用的位置。使用从php.net
上的注释中获得的信息,我最终编写了此函数:
function unzip(string $zipFile, string $destination) {
$zip = new ZipArchive();
$zip->open($zipFile);
for($i=0; $i<$zip->numFiles; $i++) {
$file=$zip->getNameIndex($i);
if(substr($file,-1) == '/') continue; // skip containing folder
$name=basename($file);
copy("zip://$zipFile#$file","$destination/$name");
}
$zip->close();
}
这是复制没有文件夹结构的单个文件。
我可以理解大多数代码,但是无法获得有关以下表达式的任何信息:
"zip://$zipFile#$file"
[我知道它在做什么(显然是从Zip存档中提取文件之一,但是任何人都可以告诉我有关zip://
协议的更多信息,以及为什么它使用#
来引用特定文件吗?] >
我正在使用ZipArchive类解压缩文件并将其内容放在有用的位置。使用从php.net上的注释中获得的信息,我最终编写了此函数:function unzip(string $ ...
签出Zip