PHP关键词高亮

2015-07-27 0 400
PHP关键词高亮

对指定的关键词进行替换处理,在html页面上高亮显示

function highlight($sString, $aWords) {
if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) {
return false;
}
$sWords = implode ('|', $aWords);
return preg_replace ('@\b('.$sWords.')\b@si', '<strong style="background-color:yellow">$1</strong>', $sString);
} 

遇见资源网 php PHP关键词高亮 http://www.ox520.com/7904.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务