好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

遍历指定目录下的所有目录和文件的php代码,需

复制代码 代码如下:

<?php 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.'<br />'; }

2: scandir 读取指定目录到数组

复制代码 代码如下:

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.'<br />'; }

查看更多关于遍历指定目录下的所有目录和文件的php代码,需的详细内容...

  阅读:42次