站内文件标题搜索如何写?我这样写很郁闷!$dir="C:\AppServ\www";
[Copy to clipboard]
PHP CODE:
function findfile ($dir, $find_sub_dir=false, $find_content=false, $except_dir=false)
{
$d = dir($dir);
while (false !== ($entry = $d->read())) {//当目录可读不为假(fasle)
if($entry == "." || $entry == ".." || in_array ($entry, $except_dir))
continue;
$file = $d->path."/".$entry;
if ( is_dir ( $file) ) //如果是目录则继续搜索
{
if ( $find_sub_dir )
{
findfile ($file, $find_sub_dir, $find_content, $except_dir) ;
}
}else//如果不是目录则
{
if ( $find_content ) //如果要查找文件内容为真
{
if ( strstr(file_get_contents($file),$find_content) ) //查找的内容为$find_content
{
// echo $file."<br>\n";
//获取正确路径
echo "http://".strstr($file,'www')."<br>\n";
}
}else
{
echo $file."<br>\n";
}
}
}
$d->close();
}
//test:
findfile ('..',true,'大家',array('templates_c','admin','xixi')) ;
-----------------------------
以上这样写就变成了只搜索文章的内容,但我想搜索文章的标题,并自动加上连接,郁闷啊,谁来改一改?