GetDotted Domains

Viewing Thread:
"Good PHP search function?"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sat 20/11/04 at 10:40
Regular
"Pouch Ape"
Posts: 14,499
Yo, wussup G'

I've had a look at PHP.net for some decent string search functions, but the best I could muster was a comparison that took the whole search term and compared it to another string. So I know that I either need to find a way of breaking down an inputted string by spaces, then comparing each individual word, or does PHP have a search function already, and I'm such a joey that I can't find it?

You have until I get back from the toilet, run my minions, run!
Sun 28/11/04 at 14:16
Regular
"Pouch Ape"
Posts: 14,499
Nah, just a simple search function, to find elements of one string in another. But couldn't find one on PHP.net. The string breakdown thing will be fine, as long as no proper Joeys try to use it with their headrods. If I was making a swear filter I'd just use the str_replace function and put in words like "sugar", or "fudge".
Sun 28/11/04 at 14:03
Regular
"It goes so quickly"
Posts: 4,083
What type of comparisons are you wanting to run (i.e. are you after something like a swear filter)?
Sun 28/11/04 at 13:53
Regular
"Pouch Ape"
Posts: 14,499
Haven't got round to writing it yet, been doing other stuff. I'll probably break up the string then run it through the texts that need comparing. I thought PHP would have had a specific search function, and not just string comparisons...although I suppose they're more or less the same. The results might be too strict though, so I'll have a look at some more methods.
Sun 28/11/04 at 13:46
Regular
"It goes so quickly"
Posts: 4,083
Did you manage to get the search function you were after?
Sat 20/11/04 at 16:13
Regular
"Pouch Ape"
Posts: 14,499
I'm back!

Cheers Garin, I'll give that a go. Didn't see "preg" on the php.net site, but I'll look it up.
Sat 20/11/04 at 15:59
Regular
"Devil in disguise"
Posts: 3,151
As far as I know theres nothing that'll do it all for you, but if you're feeling brave you could use regular expressions, eg

$search="word1 word2 word3";

// Convert the string into a regular expression

$newsearch= preg_replace("/\s+/","|",trim($search));

// sets newsearch to "word1|word2|word3"

if (preg_match("/$newsearch/","word2 is in this text")) {
echo "match found";
}

Regular expressions are a whole topic in themselves though, so maybe you'd feel more comfortable just breaking up the string
Sat 20/11/04 at 13:26
Regular
Posts: 4,279
You've spent along time on the toilet then?
Sat 20/11/04 at 10:40
Regular
"Pouch Ape"
Posts: 14,499
Yo, wussup G'

I've had a look at PHP.net for some decent string search functions, but the best I could muster was a comparison that took the whole search term and compared it to another string. So I know that I either need to find a way of breaking down an inputted string by spaces, then comparing each individual word, or does PHP have a search function already, and I'm such a joey that I can't find it?

You have until I get back from the toilet, run my minions, run!

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent
Excellent communication, polite and courteous staff - I was dealt with professionally. 10/10
Wonderful...
... and so easy-to-use even for a technophobe like me. I had my website up in a couple of hours. Thank you.
Vivien

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.