Copy code The code is as follows:
function listFiles($path){
$result = array ();
foreach(glob($path.'\'."*") as $item){
$result[strtolower($item)] = $item;
if(is_dir($ item)){
$result += listFiles($item);
}
}
return $result;
}
$path = 'E:\web\dianle' ;
foreach(listFiles($path) as $item){
echo $item.'
';
}
2: scandir read Specify directory to array
Copy code The code is as follows:
function listFiles($path){
$result = array ();
foreach( scandir($path) as $item ){
if($item != '.' && $item != '..' ){
$item = $path. '\'.$item;
$result[strtolower($item)] = $item;
if(is_dir($item)){
$result += listFiles($item);
}
}
}
return $result;
}
$path = 'E:\web\dianle';
foreach(listFiles($path) as $item) {
echo $item.'
';
}
http://www.bkjia.com/PHPjc/324517.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324517.htmlTechArticleCopy the code as follows: ?php function listFiles($path){ $result = array(); foreach(glob ($path.'\'."*") as $item){ $result[strtolower($item)] = $item; if(is_dir($item)){ $result...