btsave999
(btsave999)
新手上路

初级会员
UID 65340
精华
0
积分 13
帖子 12
金钱 13 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2005-8-1
状态 离线
|
[求助] 如何用php写出查询目录下的档名(无限层目录)呢
把下面程式copy回去,修改你要查的目录,如下
$obj->dirstart="./chatm/";
问题:只能查目录下的档案,和下一层的可查出来~~~而在下一层写不出来~~想不出来,帮忙一下^^
用途,查出该目录下档名到阵列中后将txt html htm tpl php内的文字读出,全数转为UTF-8
方便PHPBB2及Discuz....等架站机,转换utf-8用......快又简单
要如何改,才能查询无限层目录内的档名呢?
<?php
class autoutf8{
var $files;
var $i;
var $dirstart;
var $dirall;
function autoutf8(){
$this->files=array();
$this->i=0;
}
function autodir($dirs){
$dh = opendir($dirs);
while(false !== ($filename = readdir($dh))) {
$this->files[$this->i]=$filename;
$this->i++;
}
closedir($dh);
}
function checkdir(){
$numall=count($this->files);
echo $numall;
for($j=2;$j<$numall;$j++){
if(is_dir($this->dirstart.$this->files[$j]."/")==1){
$this->dirall[$j]=$this->dirstart.$this->files[$j]."/";
$this->autodir($this->dirall[$j]);
}
}
}
}
$obj=new autoutf8;
//指定你要查询的目录
$obj->dirstart="./chatm/";
$obj->autodir($obj->dirstart);
$obj->checkdir();
print_r($obj->files);
?>
|
|