I am wanting to highlight the words that the user searches for:
<?php
if(!isset($searchItem)) { $searchItem = "Orange"; }
function callback($buffer) {
global $searchItem;
// surround search item items with highlight class
return (ereg_replace($searchItem, "<span class='highlight'>$searchItem</span>", $buffer));
}
ob_start("callback");
?>
<html>
<style>
.highlight {
background: #44AA44;
color: white;
}
</style>
<body>
<p>It's like comparing bannanas to oranges to apples to peaches.
</body>
</html>
This works fine how ever if the user seached Orange instead of orange ( uppercase for the first letter ) then it does not work.
Does anyone know how to make it so it highlights the word either case
Thanks
Code: Select all