PHP关键词高亮
PHP关键词高亮 [代码片段(8行)]
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); } //该片段来自于http://outofmemory.cn
精彩图集
精彩文章