文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>利用PHP搜索指定目录下指定的文件

利用PHP搜索指定目录下指定的文件

时间:2010-05-24  来源:xhq6632

<?
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.");
       }
}
}
?>

函数描述及例子

================================

<?
       $u=new document();
      $result=$u->search("antsnet","antsnet");#first param is dir,second param is file's name
      print_r($result);
?>

相关阅读 更多 +
排行榜 更多 +
粉末星战 v1.0.0 安卓版

粉末星战 v1.0.0 安卓版

休闲益智 下载
粉末星战 v1.0.0 安卓版

粉末星战 v1.0.0 安卓版

休闲益智 下载
火线反恐部队 v1.2 安卓版

火线反恐部队 v1.2 安卓版

飞行射击 下载