Search for an exact string inside of another string

From: Date: Sun, 12 Oct 2003 00:11:50 +0000
Subject: Search for an exact string inside of another string
Groups: php.general 
Request: Send a blank email to php-general+get-165868@lists.php.net to get a copy of this message
Hi all, I have a little problem that I hope you can help me with. I have the following strings: $str1 = "Bob"; $str2 = "My Name Is Bob"; How can I get PHP to look for $str1 inside of $str2? Also, what about if "Bob" inside of $str2 is in different places? I would like something like: if ($str1 IS INSIDE OF $str2) { echo "str1 is inside of str2"; } else { echo "could not find str1 inside of str2"; } Any ideas appreciated.

« previous php.general (#165868) next »