您好,欢迎访问一九零五行业门户网

PHP遍历目录和文件列表

getdir( $dir ); if( $dirfilearray ){ foreach( $dirfilearray['dirlist'] as $handle ){ $file = $dir.ds.$handle; $dirfilearray['filelist'][$handle] = $this->getfile( $file ); } } }else{ $dirfilearray[] = '[path]:\''.$dir.'\' is not a dir or not found!'; } return $dirfilearray; } } ?>
复制代码
实例:(相对路径或绝对路径)
1.获取目录列表 getdir( $dir_dir ); print_r($getdir); ?> 显示:[html] view plaincopyarray ( [0] => example_one [1] => example_two )
复制代码
2.获取文件列表 getfile( $file_one_dir ); $getfile_two = $getdirfile->getfile( $file_two_dir ); print_r($getfile_one); print_r($getfile_two); ?>
复制代码
显示: array ( [0] => example.sql [1] => example.txt ) array ( [0] => example.php )
复制代码
3.获取目录/文件列表 getdirfile( $dir_dir ); print_r($getdirfile); ?>
复制代码
显示: array ( [dirlist] => array ( [0] => example_one [1] => example_two ) [filelist] => array ( [example_one] => array ( [0] => example.sql [1] => example.txt ) [example_two] => array ( [0] => example.php ) ) )
复制代码
文件列表, php
其它类似信息

推荐信息