Hi,
I'm kinda stumped on how to do the following:
Lets say I have a string $a, and a user supplied query $_POST['string'], I am trying to replace the user's search string in $a with a bold version of what he is searching for. So for example:
<?php
$a = "This is an apple tree.";
str_replace($POST['string'], "<strong>".$POST['string']."</strong>", $a);
print $a;
?>
That works fine, but lets say the user types his query in all caps, I can use the case insensitive version of str_replace (str_ireplace). However, the printed string will end up having letters in the middle that are all caps.
I want to keep the proper case of the original string but I can't seem to figure out a proper way of doing so. It should look like this:
user search string: APPLE
print $a: "This is an <strong>apple</strong> tree."
Thanks in advance.