当前位置: 首页 > 图文教程 > 网络编程 > PHP > listdir($dir) 目录读取函数

PHP
在PHP的图形函数中显示汉字
PHP中显示格式化的用户输入
php做饼图的函数
用PHP实现登陆验证码(类似条行码状)
PHP安全配置(1)
PHP安全配置(2)
PHP安全配置(3)
PHP安全配置(4)
水火也相容!巧妙在IIS中配置PHP调试环境
建立PHP的本地调试环境
php通用检测函数集(1)
php通用检测函数集(2)判断是否为有效网址
php通用检测函数集(3)
代码实例之php通用检测函数集(4)
php通用检测函数集(5)
使用php通过smtp发送邮件新手指南
使用PHP维护文件系统
PHP文件上传的具体思路及实现
回帖脱衣服的图片实现
用php实现qq挂机

PHP 中的 listdir($dir) 目录读取函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-19   浏览: 421 ::
收藏到网摘: n/a

  1. /** 
  2. * @ 目录读取函数, $start_dir 目录 
  3. */  
  4. function listdir($start_dir='.') {  
  5.   $files = array();  
  6.   if (is_dir($start_dir)) {  
  7.     $fh = opendir($start_dir);  
  8.     while (($file = readdir($fh)) !== false) {  
  9.       if (strcmp($file'.')==0 || strcmp($file'..')==0) continue;  
  10.       $filepath = $start_dir . '/' . $file;  
  11.       if ( is_dir($filepath) ) $files = array_merge($files, listdir($filepath));  
  12.       else array_push($files$filepath);  
  13.     }  
  14.     closedir($fh);  
  15.   }  
  16.   else {  
  17.     $files = false;  
  18.   }  
  19.   return $files;