以下用来查找匹配关键词,英文正常,可不能识别汉字,请指教,谢谢!
function makeLinkSearchable ($simply_sensitive) {
global $database;
$query = "SELECT id, name, url, description"
. "\n FROM #__simplylinks"
. "\n WHERE published = 1"
. "\n ORDER BY name DESC"
;
$database->setQuery($query);
$rows = $database->loadObjectList();
if (count($rows)) {
foreach ($rows as $row) {
$keyword = $row->name;
if ($keyword) {
// looking for the end of the keyword
$end = $keyword{strlen($keyword)-1};
$key=$keyword;
// for keywords with punctuation
if( $end == '!' || $end == '? || $end == '?' || $end == '?){
if ($simply_sensitive){
$regex = '/\b'.$key.'/';
}else{
$regex = '/\b'.$key.'/i';
}
// for standard keywords
}else{
if ($simply_sensitive){
$regex = '/\b'.$key.'\b/';
}else{
$regex = '/\b'.$key.'\b/i';
}
}
// array
$weblinks[$key]=array('id' => $row->id,'term' => $key, 'link' => $row->url, 'desc' => $row->description, 'regex' => $regex, 'found' => false);
}
}
if (isset($weblinks))
return $weblinks;
}
return array();
}
function makeLinkSearchable ($simply_sensitive) {
global $database;
$query = "SELECT id, name, url, description"
. "\n FROM #__simplylinks"
. "\n WHERE published = 1"
. "\n ORDER BY name DESC"
;
$database->setQuery($query);
$rows = $database->loadObjectList();
if (count($rows)) {
foreach ($rows as $row) {
$keyword = $row->name;
if ($keyword) {
// looking for the end of the keyword
$end = $keyword{strlen($keyword)-1};
$key=$keyword;
// for keywords with punctuation
if( $end == '!' || $end == '? || $end == '?' || $end == '?){
if ($simply_sensitive){
$regex = '/\b'.$key.'/';
}else{
$regex = '/\b'.$key.'/i';
}
// for standard keywords
}else{
if ($simply_sensitive){
$regex = '/\b'.$key.'\b/';
}else{
$regex = '/\b'.$key.'\b/i';
}
}
// array
$weblinks[$key]=array('id' => $row->id,'term' => $key, 'link' => $row->url, 'desc' => $row->description, 'regex' => $regex, 'found' => false);
}
}
if (isset($weblinks))
return $weblinks;
}
return array();
}
解决方案 »
- PHP+MYSQL查询数据库导致系统很卡!
- 这个代码有了$row为什吗还要这个while里的循环?
- 这个该怎么写??
- 含泪跪求--php调用system命令,shell可以成功运行,通过浏览器却不行
- netbeans下xdebug调试ci框架程序 浏览器显示forbidden
- 如何将[biao.frm][biao.MYD][biao.MYI]上传到服务器的MYSQL数据库中?
- imagemagick叠图
- 谁可以提供一个qmail_v1.54的下载链接或是谁有可以发一个给我吗?
- ZendStudio5.1序列号
- 如何用PHP将MYSQL数据库里的数据导入EXCEL?
- dedecms后台添加文章时无法使用粘贴功能?
- 想找一位能远程辅导的php老师
这样的语句实在让人看不懂
呵呵,应该也有语法错误。