I want to highlight my keyword search text by using preg_replace in php but the problem is it won't work with parentheses string ( and )
My function look like this...
$text_oritinal = "25 Hours: Colour In White (CD)";
function highlight($text_search, $text_original) {
$str = preg_replace('#'. $text_search .'#i', '<span style="background-color:#FFFF66; color:#FF0000;">\\0</span>', $text_original);
return $str;
}
Full original text is "25 Hours: Colour In White (CD)"
For example. If I use the keyword
$text_search = "25 Hours: Colour In White";
It return good replaced keyword with highlight background and text color.
<span style="background-color:#FFFF66; color:#FF0000;">25 Hours: Colour In White</span> (CD)
but! if I use this keyword included parentheses string ( and )
$text_search = "25 Hours: Colour In White (CD)";
It NOT return replaced background and text color.
I think it stuck with parentheses string ( and )
The question is how to highlight all text keyword matched without any problem with parentheses string ( and )?
Please share your idea. Thanks :)