/ Published in: PHP
You may use this code to highlight specific words in your displaying search results.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function highlight($str, $words){ return false; } '@\b('.$arr_words.')\b@si', '<strong style="background-color:yellow">$1</strong>', $str ); } ?>
URL: http://www.apphp.com/index.php?snippet=php-highlight-specific-words-in-a-phrase