d
Amit DhamuSoftware Engineer
 

Highlight Search Keyword

1 minute read 00000 views
$sentence = "The Quick Brown Fox";
$search = "fox";

$highlighted_sentence = preg_replace("/($search)/i", "<mark>$1</mark>", $sentence);