btw, you may want to search for a name surrounded by spaces as philip vs
philips, jim vs jimmy, etc.  probably other considerations as well, or
maybe not :)

philip


On Fri, 31 Aug 2001, Philip Olson wrote:

> try this :
> 
>   $people  = array ('philip','sasheen','jim');
>   $string  = 'Hi, my name is philip, I miss Sasheen';
> 
>   foreach ($people as $person) {
>  
>     if (stristr($string,$person)) {
>       $matches[] = $person;
>     }
>   }
>  
>   // results live in $matches now.
> 
>   print_r($matches);
> 
> stristr is case insensitive, strstr is case sensitive.  modify to suit
> your needs.
> 
> regards,
> Philip Olson
> 
> 
> On Fri, 31 Aug 2001, Joseph Bannon wrote:
> 
> > What about going the other way? Say I have a sentence...
> > 
> > "Hi, my name is Bob."
> > 
> > ...and I want to search the sentence for one of the values (people) in the
> > array...
> > 
> > $people = array("Jim","John","JP","Bob");
> > 
> > Can this be done?
> > 
> > 
> > Thanks,
> > Joseph
> > 
> > 
> > 
> > 
> > -----Original Message-----
> > 
> > yes, in_array($person, $people)!
> > 
> > however, you may take a look into the manual.
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to