以下用来查找匹配关键词,英文正常,可不能识别汉字,请指教,谢谢!
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();
}