<?php
$searchforfile = "les thugs - 1999 - tout doit disparaitre (lp) [www.pirate-punk.net].zip";
$root = $_SERVER['DOCUMENT_ROOT'];
$search = preg_quote(utf8_decode($searchforfile));
function rsearch($folder, $pattern) {
$dir = new RecursiveDirectoryIterator($folder);
$ite = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
$fileList = array();
foreach($files as $file) {
$fileList = array_merge($fileList, $file);
}
return $fileList;
}
$resultatss = rsearch($root, '/.*\/'.$search.'/');
foreach ($resultatss as $resultat) {
$downloadlink = str_replace("$root/", "", $resultat);
$za = new ZipArchive();
$za->open($downloadlink);
for( $i = 0; $i < $za->numFiles; $i++ ){
$stat = $za->statIndex( $i );
$toune = basename( $stat['name'] );
echo "$toune <br>";
}
}
?>
此脚本将列出ZIP存档中的所有文件,然后回显每个文件的名称。
现在我在确定如何按字母顺序排序文件名($ toune)时遇到了一些麻烦
谢谢
答案 0 :(得分:1)
尝试asort
喜欢
for( $i = 0; $i < $za->numFiles; $i++ ){
$stat = $za->statIndex( $i );
$toune_arr[] = basename( $stat['name'] );
}
asort($toune_arr);
print_r($toune_arr);
请参阅此LINK