Date: 08/31/01
- Next message: Alexander Skwar: "Re: [PHP] PHP_SELF or REQUEST_URI within Function ?"
- Previous message: Jon Thompson Coon: "[PHP] passing variables between scripts?"
- Maybe in reply to: Joseph Bannon: "[PHP] array search"
- Next in thread: Joseph Bannon: "RE: [PHP] array search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Joseph,
The below postings are what you're looking for. Hopefully the in_array PHP
function uses a smart search algorithm and doesn't go through the entire
array. If you store your values in a db you can make use of an index on the
column, or you could write your own search algorithm that uses a btree or
some other type of search methodology.
Johan
-----Original Message-----
From: Papp Gyozo [mailto:pgerzson <email protected>]
Sent: Friday, August 31, 2001 10:02 AM
To: Joseph Bannon; PHP (E-mail)
Subject: Re: [PHP] array search
yes, in_array($person, $people)!
however, you may take a look into the manual.
----- Original Message -----
From: Joseph Bannon <JBannon <email protected>>
To: PHP (E-mail) <php-general <email protected>>
Sent: Friday, August 31, 2001 5: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>
- Next message: Alexander Skwar: "Re: [PHP] PHP_SELF or REQUEST_URI within Function ?"
- Previous message: Jon Thompson Coon: "[PHP] passing variables between scripts?"
- Maybe in reply to: Joseph Bannon: "[PHP] array search"
- Next in thread: Joseph Bannon: "RE: [PHP] array search"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

