Highlight words in a phrase

Highlight words in a phrase

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);
}