I am building a search that will wrap the searched text with a <span> tag and i have this code working ok:
str_ireplace($q,'<span>'.$q.'</span>',$row[name]);
The problem is, if a user searches for Tom is will show Tom which is cool, but if they put in tom because of the str_ireplace it would show tom, does that make sense? The real issue is if someone entered tOm aRnFeLd although it would search ok, the aesthetics would actually show up on the page tOm aRnFeLd
How can i retain the capital letters and lower case 'ness of both strings? Is there a better way to wrap case insensitive text from a string?