它返回一個(gè)含有所有文件的列表包含搜索詞語數(shù)組。

復(fù)制代碼 " /> 日韩区欧美区,9299yy看片淫黄大片在线,涩涩漫画网

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

Search File Contents PHP 搜索目錄文本內(nèi)容的代碼

這個(gè)類可以用來搜索在給定的文本目錄中的文件。
它可以給定目錄遍歷遞歸查找某些文件擴(kuò)展名的文件。
并打開找到的文件,并檢查他們是否包含搜索詞語。

它返回一個(gè)含有所有文件的列表包含搜索詞語數(shù)組。

復(fù)制代碼 代碼如下:
<?php
/*
Class for searching the contents of all the files in a directory and its subdirectories
For support please visit http://www.webdigity.com/
*/
class searchFileContents{
var $dir_name = '';//The directory to search

var $search_phrase = '';//The phrase to search in the file contents
var $allowed_file_types = array('php','phps');//The file types that are searched
var $foundFiles;//Files that contain the search phrase will be stored here
//開源代碼OSphp.COM.Cn
var $myfiles;
function search($directory, $search_phrase){
$this->dir_name = $directory;
$this->search_phrase = $search_phrase;

$this->myfiles = $this->GetDirContents($this->dir_name);
$this->foundFiles = array();
if ( empty($this->search_phrase) ) die('Empty search phrase');

if ( empty($this->dir_name) ) die('You must select a directory to search');
foreach ( $this->myfiles as $f ){
if ( in_array(array_pop(explode ( '.', $f )), $this->allowed_file_types) ){ //開源OSphp.COM.CN
$contents = file_get_contents($f);
if ( strpos($contents, $this->search_phrase) !== false )
$this->foundFiles [] = $f;
//開源代碼OSphp.COm.CN

}
}
return $this->foundFiles;
}
function GetDirContents($dir){
if (!is_dir($dir)){die ("Function GetDirContents: Problem reading : $dir!");}
if ($root=@opendir($dir)){
//php開源代碼

while ($file=readdir($root)){
if($file=="." || $file==".."){continue;}
if(is_dir($dir."/".$file)){

$files=array_merge($files,$this->GetDirContents($dir."/".$file));
}else{
$files[]=$dir."/".$file; //開源OSphp.COM.CN
}
}
}
return $files;
}
}
//Example :
$search = new searchFileContents;
$search->search('E:/htdocs/AccessClass', 'class'); //開源代碼OSphp.COM.Cn
var_dump($search->foundFiles);
?>

php技術(shù)Search File Contents PHP 搜索目錄文本內(nèi)容的代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产精品免费视频网站 | 97狠狠操| 小说专区图片专区 | 免费伦费一区二区三区四区 | 欧洲视频在线观看 | 91亚洲精品国产自在现线 | 免费人成在线视频播放2022 | 激情欧美一区二区三区中文字幕 | 亚洲日本激情综合在线观看 | 中文字幕日韩专区精品系列 | 久久久精品免费国产四虎 | 成人国产在线24小时播放视频 | 韩国美女一区二区 | 亚洲乱码在线观看 | 中文字幕日韩三级 | 国产91边对白在线播放 | 亚洲韩国日本欧美一区二区三区 | 日韩一区二区在线免费观看 | 美国成人影院 | 色噜噜视频 | 精品久久久久久久一区二区手机版 | 精品亚洲一区二区三区 | 四虎永久在线观看免费网站网址 | 亚洲成人在线播放 | 欧美一区二区三区在线可观看 | 美女免费黄 | 99国产精品免费视频 | 美女很黄很黄是免费的·无遮挡网站 | 婷婷久久综合九色综合绿巨人 | 国产片欧美片亚洲片久久综合 | 丁香婷婷综合网 | 午夜久久久久久网站 | 亚洲乱强伦 | 韩日成人 | 国产精品亚洲高清一区二区 | 在线xx视频| 欧美另类极品videosbest视频 | 91视频国产免费 | 黄色免费在线观看视频 | 精品小视频 | 精品免费国产一区二区三区 |