如何遍历文件夹及子孙文件夹?(方法三:存成数组) 收藏
2009年02月12日


我曾测试过多种遍历文件夹的方法,以下写的的均是通过测试的

这个是我用的最多的,用它实现了多种变种:

它的好处是写进了数组,比直接echo的稍难了一些!

function get_all_files($path) {

$list = array();

foreach( glob( $path . '\*') as $item ) {

if( is_dir($item ) ) {

$list = array_merge( $list , get_all_files( $item ) );

} else {

$list[] = $item;

}

} return $list;

}

上面这个是别人写的代码,测试也通过!也拿来分享一下,但也用了glob!

 

本文永久链接: http://www.zzxj.net/blog/fxs_2008/archive/2009/02/12/23.html

发表于 @ 2009年02月12日 |评论(loading... )|收藏

发表评论 姓  名: