当前位置: 首页 > 图文教程 > 网络编程 > PHP > listdir($dir) 目录读取函数
PHP 中的 listdir($dir) 目录读取函数
出处:互联网 整理: 软晨网(RuanChen.com) 发布: 2009-08-19 浏览: 381 ::
收藏到网摘:
n/a
-
-
-
- function listdir($start_dir='.') {
- $files = array();
- if (is_dir($start_dir)) {
- $fh = opendir($start_dir);
- while (($file = readdir($fh)) !== false) {
- if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
- $filepath = $start_dir . '/' . $file;
- if ( is_dir($filepath) ) $files = array_merge($files, listdir($filepath));
- else array_push($files, $filepath);
- }
- closedir($fh);
- }
- else {
- $files = false;
- }
- return $files;
- }