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 ) ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.