Date: 08/31/01
- Next message: Kunal Jhunjhunwala: "[PHP] Getting links from html page"
- Previous message: Philip Olson: "RE: [PHP] array search"
- In reply to: Philip Olson: "RE: [PHP] array search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: php-general-unsubscribe <email protected>
> > For additional commands, e-mail: php-general-help <email protected>
> > To contact the list administrators, e-mail: php-list-admin <email protected>
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe <email protected>
> For additional commands, e-mail: php-general-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Kunal Jhunjhunwala: "[PHP] Getting links from html page"
- Previous message: Philip Olson: "RE: [PHP] array search"
- In reply to: Philip Olson: "RE: [PHP] array search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

