清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
php遍历某文件夹下的所有文件和文件夹
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function list_dir( $dirpath ){ if ( $dirpath [ strlen ( $dirpath )-1]!= "\\" ){ $dirpath .= "\\" ;} static $result_array = array (); if ( is_dir ( $dirpath )){ $handle =opendir( $dirpath ); while ( $file =readdir( $handle )){ if ( $file == "." || $file == ".." ){ continue ;} if ( is_dir ( $dirpath . $file )){ list_dir( $dirpath . $file . "\\" ); } else { array_push ( $result_array , $dirpath . $file ); } } closedir ( $handle ); } return $result_array ; } $array =list_dir( "D:\www" ); foreach ( $array as $value ){ echo $value ; echo "<br>" ; } |