PHP遍历目录和文件
<?php function listFiles($path){ $result = array(); foreach(glob($path.'\\'."*") as $item){ $result = $item; if(is_dir($item)){ $result += listFiles($item); } } return $result; } $path = 'E:\\web\\dianle'; foreach(listFiles($path) as $item){ echo $item.'<br />'; } php?>function listFiles($path){ $result = array(); foreach( scandir($path) as $item ){ if($item != '.' && $item != '..' ){ $item = $path.'\\'.$item; $result = $item; if(is_dir($item)){ $result += listFiles($item); } } } return $result; } $path = 'E:\\web\\dianle'; foreach(listFiles($path) as $item){ echo $item.'<br />'; }
这是2012前的最后一篇文章了。
页:
[1]