Re: [PHP] array search From: Philip Olson (philip <email protected>)
Date: 08/31/01

just to add some info. rememember this is case sensitive and spaces do
matter, sometimes (depending on your goals) the following will apply :

  $good_names = array('jim','philip','sasheen');

  $my_name = 'PHiliP';

  if (in_array(trim(strtolower($my_name)),$good_names))

and, another good function is array_keys and array_search. see :

  http://www.php.net/array

regards,
Philip Olson

On Fri, 31 Aug 2001, Andrey Hristov wrote:

> from http://php.net/quickref.php
>
> $os = array ("Mac", "NT", "Irix", "Linux");
> if (in_array ("Irix", $os)){
> print "Got Irix";
> }
>
> Andrey HristovIcyGEN Corporationhttp://www.icygen.comBALANCED SOLUTIONS
> ----- Original Message -----
> From: "Joseph Bannon" <JBannon <email protected>>
> To: "PHP (E-mail)" <php-general <email protected>>
> Sent: Friday, August 31, 2001 6:40 PM
> Subject: [PHP] array search
>
>
> > I have an array of names, like below...
> >
> > $people = array("Jim","John","JP");
> >
> > Is there a way in an IF statement to see if someone's name is in the array?
> > Like...
> >
> > if ($people =~ $person) { }
> >
> > I don't want to have to create a foreach loop to go through the array to see
> > if that person is there.
> >
> > Joseph
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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>