glob() 函数遍历查找
PHP 2017年3月4日
<?php
function findFile($pathName, $exts=''){
if(!empty($exts)){
for($i=0,$limit=count($exts); $i<$limit; $i++){
$exts[$i] = "*.".$exts[$i];
}
$filter = (!$exts)?"*":"{".implode(",",$exts)."}";
$pattern = $pathName."/".$filter;
return glob($pattern, GLOB_BRACE);
}
}
$arr = findFile($pathName, array(ext1, ext2));
print_r($arr);
?>