Discuz教程网

php遍历文件夹下的所有文件和子文件夹

[复制链接]
authicon dly 发表于 2011-1-11 19:29:58 | 显示全部楼层 |阅读模式
  1. function my_scandir($dir)
  2. {
  3.      $files = array();
  4.      if ( $handle = opendir($dir) ) {
  5.          while ( ($file = readdir($handle)) !== false ) {
  6.              if ( $file != ".." && $file != "." ) {
  7.                  if ( is_dir($dir . "/" . $file) ) {
  8.                      $files[$file] = scandir($dir . "/" . $file);
  9.                  }else {
  10.                      $files[] = $file;
  11.                  }
  12.              }
  13.          }
  14.          closedir($handle);
  15.          return $files;
  16.      }
  17. }
复制代码






上一篇:php多维数组转化成对象
下一篇:header中Content-type的种类
authicon soul2511 发表于 2011-6-18 08:59:45 | 显示全部楼层
顶顶更健康
authicon 蓝天blue 发表于 2011-6-21 13:00:01 | 显示全部楼层
顶你一下,好贴要顶!
authicon 风中徜徉 发表于 2011-6-21 14:59:51 | 显示全部楼层
继续来索要
authicon 馥郁渊汀 发表于 2011-6-22 10:59:49 | 显示全部楼层
真的有意思!
authicon cutiemimi 发表于 2011-6-22 16:00:03 | 显示全部楼层
哈哈,支持了
authicon haidideyu 发表于 2011-6-24 11:00:20 | 显示全部楼层
我回不回呢 考虑再三 还是不回了吧 ^_^
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-4 05:10

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表