Home > php教程 > php手册 > body text

PHP文本数据库的搜索方法

WBOY
Release: 2016-06-21 09:10:09
Original
1221 people have browsed it

数据|数据库



//PHP文本数据库的搜索方法
searchstr=("/".preg_quote($searchstr)."/");
//$searchstr是查找的关键字
$records=file($file);//获取所有的记录数
//$file是查找的数据文件
$search_reocrds=preg_grep ($searchstr, $records);//开始查找记录
//$search_reocrds为查找到的记录数
unset($records);
if($search_records){
//开始显示记录,写下你自己的处理程序********************
while (list ($key, $val) = each ( $search_records)) {
echo "$val";
}
//****************************************************
}

?>



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template