Replace the specified keywords and highlight them on the html page
- 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', $sString);
- }
Copy code
|