打开APP
未登录
开通VIP,畅享免费电子书等14项超值服
开通VIP
首页
好书
留言交流
下载APP
联系客服
搜索结果检测关键字高亮显示
丶平上
>《php》
2017.05.15
关注
//高亮显示函数
function bat_highlight($message,$words,$
color
=
'#ff0000'
){
if(!empty($words)){
$
highlightarray
=
explode
('+',$words);
$
sppos
=
strrpos
($message,chr(0).chr(0).chr(0));
if($sppos!==FALSE){
$
specialextra
=
substr
($message,$sppos+3);
$
message
=
substr
($message,0,$sppos);
}
$
message
=
preg_replace
(array("/(^|
>
)([^
<
]+)(?=
<
|$)/sUe","/
<
highlight
>
(.*)
<
\/highlight
>
/siU"),array("\highlight('\\2', \$highlightarray, '\\1')","
<
strong
>
<
font
color
=\"$color\"
>
\\1
</
font
>
</
strong
>
"),$message);
if($sppos!==FALSE){
$
message
= $message.chr(0).chr(0).chr(0).$specialextra;
}
}
return $message;
}
function highlight($text, $words, $prepend) {
$
text
=
str_replace
('\"', '"', $text);
foreach($words AS $
key
=
>
$replaceword) {
$
text
=
str_replace
($replaceword, '
<
highlight
>
'.$replaceword.'
</
highlight
>
', $text);
}
return "$prepend$text";
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报
。
打开APP,阅读全文并永久保存
查看更多类似文章
猜你喜欢
类似文章
【热】
打开小程序,算一算2024你的财运
Sublime Text3 BracketHighlighter高亮色彩配置
程序员必备的 JavaScript 源代码,程序员可是一般不公开的哦
雅思口语| Part1: text message 短信息
高亮网络设置
代码高亮
介绍几款wordpress代码高亮插件
更多类似文章 >>
生活服务
热点新闻
留言交流
回顶部
联系我们
分享
收藏
点击这里,查看已保存的文章
导长图
关注
一键复制
下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!
联系客服
微信登录中...
请勿关闭此页面
先别划走!
送你5元优惠券,购买VIP限时立减!
5
元
优惠券
优惠券还有
10:00
过期
马上使用
×