robert_gsfame Posted July 13, 2010 Share Posted July 13, 2010 i have this function to highlight search text function highlightWords($text, $words) { foreach ($words as $word) { $word = preg_quote($word); $text = preg_replace("/\b($word)\b/i", '<span class="highlight_word">\1</span>', $text); } return $text; } ?> if i want to highlight let say "Mr" and "George" from "Let me introduce you to Mr George" I found that the word George missing after the word "Mr" highlighted Link to comment https://forums.phpfreaks.com/topic/207605-preg_replace-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.