Re: in_array() 4.0.0 -> 4.0.2
| From: | Robin Vickery | Date: | Fri, 08 Sep 2000 09:10:56 +0000 |
| Subject: | Re: in_array() 4.0.0 -> 4.0.2 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15847@lists.php.net to get a copy of this message | ||
davidn@vnvi.com ("David Newcomb") writes:
> Rasmus,
>
> The purpose of in_array() is to say if an item is in the array,
> with a rather nice side effect of re-positioning the array pointer
> to that element.
>
> How are we to find the position of the element?
>
> I don't want to have to do an expensive for loop every time I
> want to get an index.
>
> Short of coding up a my_in_array() what are the alternatives?
$keys = array_keys( $foo, "bar")
Returns a list of all the keys of $foo where the value is "bar".
-robin
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)870 729 5444