CanMan2004 Posted July 6, 2006 Share Posted July 6, 2006 Hi allI have a database which holds lots of text, I have made a simple search system. What I want to do is to highlight the word they searched, they way I thought of doing it was[code]<? print strtr($row['text'], "'".$_GET['searchterm']."'", "<strong>'".$_GET['searchterm']."'</strong>"); ?>[/code]But then found that I cannot use html within that tag and also it is case sensative, so if someone searches for Internet and the word is stored as internet, then it wouldnt find it. Can anyone help?Thanks in advance as alwaysDave Quote Link to comment https://forums.phpfreaks.com/topic/13846-highligting-words/ Share on other sites More sharing options...
.josh Posted July 6, 2006 Share Posted July 6, 2006 is that strtr a typo and you meant str[b]s[/b]tr? strtr and strstr are two different functions. i suspect that you meant to use strstr(). if you are using the first, strtr() takes 2 arguments, not 3, as you have. I suspect that's why you "cant" use html. and as far as case sensitivety, use str[b]i[/b]str() instead of strstr, as it is case in-sensitive. Quote Link to comment https://forums.phpfreaks.com/topic/13846-highligting-words/#findComment-53889 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.