standers Posted March 7, 2010 Share Posted March 7, 2010 Can someone please tell me how for find more than one keyword in a string?I'm new at php so a little help would be greatly appreciated. I have read the php manual on strpos at http://www.php.net/manual/en/function.strpos.phpbut I can't find out how to search a string for more than one word.<?php$mystring = 'pets';$findme = 'dog';$pos = strpos($mystring, $findme);but I would like to have $findme = 'dog'; also search for cat, dog, birdthank you for any help you can provide. Link to comment Share on other sites More sharing options...
Synook Posted March 7, 2010 Share Posted March 7, 2010 If you want to find the first position for any of "cat", "dog" or "bird", then you can do three calls to strpos(), one for each, and then find out which result is the smallest (you could automate this using a loop). For more complex situations, maybe have a look at regular expressions. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.