Jump to content

Archived

This topic is now archived and is closed to further replies.

CanMan2004

Highligting words

Recommended Posts

Hi all

I 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 always

Dave

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.