PHP高亮关键词

2015-01-17 0 841
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/7222.html

常见问题

相关文章

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

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