Re: getting numeric index of array
| From: | CC Zona | Date: | Sun, 25 Mar 2001 23:09:09 +0000 |
| Subject: | Re: getting numeric index of array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45534@lists.php.net to get a copy of this message | ||
In article <5.0.0.25.2.20010325185534.02408cf0@pop-gw.vento.com.br>,
lemming@vento.com.br (Christian Dechery) wrote:
> $myArray = array(
> "one" => "something",
> "two" => "otherthing",
> "three" => "whatever"
> );
>
> I want to, given the key (or value), it returns me the numeric index for
> that ocurrence... examples:
>
> given "one" -> returns 0
> given "whatever" -> returns 2
> given "two" -> returns 1
> given "four" -> returns NULL or false...
http://php.net/manual/en/function.array-search.php
(It's only avaliable in PHP4 CVS so far, but see the annotations for
examples of user functions to do the same thing.)
--
CC