欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP实现查找指定目录下指定的文件_PHP教程

程序员文章站 2022-04-09 13:00:05
...
class document{
private $file_array
=array();
private $folder_array
=array();
private $all_array
=array();
function
search($path,$file
){
if(
is_dir($path
)){
$H=opendir($path
);
while(
false!==($_file=readdir($H
))){
if(
is_dir($path."/".$_file)&&$_file!="." && $_file!=".." && $_file!=="Thumbs.db"
){
if(
eregi($file,$path."/".$_file
)){
array_push($this->folder_array,$path."/".$_file
);
}
$this->search($path."/".$_file,$file
);
}elseif(
is_file($path."/".$_file)&&$_file!="." && $_file!=".." && $_file!=="Thumbs.db"
){
if(
eregi($file,$_file
)){
array_push($this->file_array,$path."/".$_file
);
}
}
}
$this->all_array["folder"]=$this->folder_array
;
$this->all_array["file"]=$this->file_array
;
return
$this->all_array
;
closedir($H
);
}elseif(
is_file($path
)){
if(
eregi($file,$path
)){
$this->all_array["file"]=$path
;
}
return
$this->all_array
;
}else{
return
$this->error("this folder does not exits,please check it out."
);
}
}
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486238.htmlTechArticle?php class document { private $file_array =array(); private $folder_array =array(); private $all_array =array(); function search ( $path , $file ){ if( is_dir ( $path )){ $H = open...