dpc Posted October 13, 2008 Share Posted October 13, 2008 Hi, I'm searching through a database I have for keywords and can get the correct search results to display in a table and highlight the results, but the method I am using replaces any upper/lower case letters with whatever the search term was. (In my case $trimmed). Could anybody help me find a better solution than using eregi_replace ? Example below:- <? echo eregi_replace( $trimmed, "<span class=\"searchresults\">".$trimmed."</span>", $EntryID ) ?> Link to comment https://forums.phpfreaks.com/topic/128190-highlighting-search-results-case-insensitive/ Share on other sites More sharing options...
Orio Posted October 13, 2008 Share Posted October 13, 2008 Try using: <?php preg_replace("#(".preg_quote($trimmed,'#').")#i", "<span class=\"searchresults\">$1</span>", $EntryID); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/128190-highlighting-search-results-case-insensitive/#findComment-663907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.