Discuz教程网

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

[复制链接]
authicon 星火燎原 发表于 2011-5-21 22:34:12 | 显示全部楼层 |阅读模式
  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字符串处理函数大全
下一篇:PHP header中Content-type的种类
authicon nmzc 发表于 2011-5-23 21:59:35 | 显示全部楼层
感谢分享  收下了·····
authicon fantuanzi 发表于 2011-5-26 00:59:50 | 显示全部楼层
支持楼主,顶一下
authicon 卡卡猫 发表于 2011-5-28 16:59:36 | 显示全部楼层
这个还是不错的!
authicon NicoleOnly 发表于 2011-6-19 23:00:08 | 显示全部楼层
好辛苦才找到啊
authicon haidideyu 发表于 2011-6-21 13:00:03 | 显示全部楼层
好像不错的样子
authicon 乐娃娃 发表于 2011-6-21 13:59:47 | 显示全部楼层
喜欢喜欢喜欢
authicon 风中徜徉 发表于 2011-6-25 14:59:44 | 显示全部楼层
好像不错的样子
authicon 婷婷爱牛牛 发表于 2011-6-27 20:59:47 | 显示全部楼层
好像不错的样子
authicon soul2511 发表于 2011-8-9 15:47:24 | 显示全部楼层
好东东下下来看看
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-3 01:35

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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