问个白痴的问题,如何读取目录?
本帖最后由 couth 于 2013-6-10 13:27 编辑比如目录结构如下:
tpl
red
blue
black
我写了以下函数,为什么总是读不到内容呢(我的目的就是想读取子目录名,而不是文件名)
搞定了,函数写的有问题。 本帖最后由 去年明日 于 2013-6-11 15:07 编辑
<?php
//打开 tpl目录
$handle = opendir("tpl"); // 这个路径不能错
//列出 images 目录中的文件
while (($file = readdir($handle)) !== false){
if ($file != '.' && $file != '..' && is_dir($file)) // 去除特殊的目录
{
echo "filename: " . $file . "<br />";
}
}
closedir($dir);
?> 去年明日 发表于 2013-6-11 15:04 static/image/common/back.gif
谢谢了。写的不错。
页:
[1]