How to find a word from a 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
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

How to find a word from a string?

Post by myleow »

If i have a

Code: Select all

string  A = "./Contacts";
AND

Code: Select all

string B = "./C\System\Data\Contacts.dba";
is there a way to find if the word "Contacts" exist in these two strings?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

preg_match('#\bContacts\b#',$string);
Post Reply