Hi What you are looking for is a regular expression function, I would suggest the following:
if(ereg($str1, $str2) == 1) { /*Found Bob in string*/ } else { /*didn't find Bob } Rory McKinley Nebula Solutions +27 82 857 2391 [EMAIL PROTECTED] "There are 10 kinds of people in this world, those who understand binary and those who don't" (Unknown) ----- Original Message ----- From: "PHP Webmaster" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, October 12, 2003 2:11 AM Subject: [PHP] Search for an exact string inside of another string > 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. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php