string contains string?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
xyrial
Forum Newbie
Posts: 3
Joined: Fri Jun 27, 2003 7:53 pm

string contains string?

Post by xyrial »

I'll to explain my question: I have an string (url) and want to know wich searchengine it comes from.

the string is: "http://www.google.com/search?sourceid=n ... devnetwork"

and want php to let me know if string "google", "altavista" or something is in that string. How can i do that?

Do i have to use 'parse_str'? Or what? Switch/cases?

Please help me!
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

I use strstr, or stristr for a case-insensitive version.

Code: Select all

$string1 = "my favourite search engine is GOOGLE, ovbiously!";
$string2 = "oogle";
if (stristr($string1,$string2)){
//yep, it found it.
}
User avatar
xyrial
Forum Newbie
Posts: 3
Joined: Fri Jun 27, 2003 7:53 pm

Post by xyrial »

Thanx!! work's great ;)
Post Reply