Created
November 14, 2015 22:28
-
-
Save d1i1m1o1n/edf0605aabeaaa5ef7f9 to your computer and use it in GitHub Desktop.
PHP highlight words in text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (explode(' ', $_REQUEST["q"]) as $key => $value) { | |
$arItem["NAME"] = preg_replace('/'.$value.'/iu', '<span class="search-term">\\0</span>', $arItem["NAME"]); | |
$arItem["PREVIEW_TEXT"] = preg_replace('/'.$value.'/iu', '<span class="search-term">\\0</span>', $arItem["PREVIEW_TEXT"]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment