finding a word in a text 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
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

finding a word in a text string

Post by evilcoder »

hey guys, say $str = "hello, i'm running through a proxy to your site"
Is there a function that would allow me to search for the word proxy in that string, and if it finds it do one thing, and if it doesn't to do something else?

thanks
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

[php_man]strstr[/php_man]

Code: Select all

if(strstr($haystack,$needle)!==false)
  //do something
else
  //do something else
Post Reply