What is the best way to highlight search terms in PHP without changing their case?

When highlighting search terms in PHP without changing their case, you can use the `preg_replace` function with the `i` modifier to perform a case-insensitive search and replace. This allows you to highlight the search terms without altering their original case.

$searchTerm = "example";
$text = "This is an example sentence to demonstrate highlighting search terms in PHP.";

$highlightedText = preg_replace('/\b' . preg_quote($searchTerm, '/') . '\b/i', '<strong>$0</strong>', $text);

echo $highlightedText;