打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
搜索结果检测关键字高亮显示
  1. //高亮显示函数  
  2. function bat_highlight($message,$words,$color = '#ff0000'){  
  3.     if(!empty($words)){  
  4.         $highlightarray = explode('+',$words);  
  5.         $sppos = strrpos($message,chr(0).chr(0).chr(0));  
  6.         if($sppos!==FALSE){  
  7.             $specialextra = substr($message,$sppos+3);  
  8.             $message = substr($message,0,$sppos);  
  9.         }  
  10.         $message = preg_replace(array("/(^|>)([^<]+)(?=<|$)/sUe","/<highlight>(.*)<\/highlight>/siU"),array("\highlight('\\2', \$highlightarray, '\\1')","<strong><font color=\"$color\">\\1</font></strong>"),$message);  
  11.         if($sppos!==FALSE){  
  12.             $message = $message.chr(0).chr(0).chr(0).$specialextra;  
  13.         }  
  14.     }  
  15.     return $message;  
  16. }  
  17. function highlight($text, $words, $prepend) {  
  18.     $text = str_replace('\"', '"', $text);  
  19.     foreach($words AS $key => $replaceword) {  
  20.         $text = str_replace($replaceword, '<highlight>'.$replaceword.'</highlight>', $text);  
  21.     }  
  22.     return "$prepend$text";  
  23. }  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Sublime Text3 BracketHighlighter高亮色彩配置
程序员必备的 JavaScript 源代码,程序员可是一般不公开的哦
雅思口语| Part1: text message 短信息
高亮网络设置
代码高亮
介绍几款wordpress代码高亮插件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服