This function will highlight the $word in the $string. This function is used in the search when highlighting words after a search.
Quote
highlight_words ( array $word, string $subject )
<?php
$words = array (
0 => "lemon",
1 => "banana"
);
$subject = "banana, apple, orange and lemon";
echo highlight_words($words, $subject);
?>
Quote
<span style='background-color:yellow;font-weight:bold;padding-left:2px;padding-right:2px'>banana</span>, apple, orange and <span style='background-color:yellow;font-weight:bold;padding-left:2px;padding-right:2px'>lemon</span>
<?php
$word = "lemon banana";
$words = explode(" ", $word);
$subject = "banana, apple, orange and lemon";
echo highlight_words($word1, $subject);
?>
Quote
<span style='background-color:yellow;font-weight:bold;padding-left:2px;padding-right:2px'>banana</span>, apple, orange and <span style='background-color:yellow;font-weight:bold;padding-left:2px;padding-right:2px'>lemon</span>