search highlight
Hi, is there any way to add matching text highlights to table search. It's way better for UX. We can see an example of it on this forum search as well.
function highlightMatch($text, $pattern) {
$highlighted = preg_replace('/(' . preg_quote($pattern, '/') . ')/i', '<span class="highlight">$1</span>', htmlspecialchars($text));
return $highlighted;
}foreach ($users as $user) {
$user->name = highlightMatch($user->name, 'rup');
$user->email = highlightMatch($user->email, 'rup');
$user->contact = highlightMatch($user->contact, 'rup');
// Do this for any other fields you wish to highlight.
}