Why we are getting above error. When we run below code inside a for loop which is running more than 500.
$text22 = preg_replace('/\S*\b('. $searchphrase[$rr] .')\b\S*/i', '<b><a href='.$bbb.' data-color='.$colors1[$clx].','.$colors2[$clx].','.$colors3[$clx].'>$1</a></b>', $aaa);
It's likely that the dynamic string you are placing into your regex contains characters that are special to regular expressions. An open parenthesis in the string would cause the "unmatched parentheses" error, and "at offset 8" is the second hint the issue is here. You should wrap regex variables in preg_quote
:
'/\S*\b('. preg_quote($searchphrase[$rr]) .')\b\S*/i'