时间:2021-07-01 10:21:17 帮助过:3人阅读
function listdir($dir){
$this->dirname=$dir;
$this->depth=0;
$this->tostring=”";
}
//把结果保存进多维数组
function getlist($dir=”"){
if($dir==”")$dir=$this->dirname;
$d=@dir($dir);
while(false!==($item=$d->read()))
{
if($item!=”.”&&$item!=”..”)
{
$path=$dir.”/”.$item;
if(is_dir($path)){
$this->depth+=1;
$this->getlist($path);
}else{
$this->list[$this->depth][]=$item;
}
}
}
$this->list[$this->depth]['directory']=$dir;
$this->depth-=1;
$d->close();
return $this->list;
}
//字符窜化结果
function tostring($dir=”"){
if($dir==”")$dir=$this->dirname;
$d=@dir($dir);
$this->tostring.=”
输出结果:
http://www.bkjia.com/PHPjc/477448.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477448.htmlTechArticle?php class listdir{ var $depth; var $dirname; var $list; var $tostring; function listdir($dir){ $this-dirname=$dir; $this-depth=0; $this-tostring=; } //把结果保存进多维数组...