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...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn