Re: in_array() 4.0.0 -> 4.0.2
| From: | David Newcomb | Date: | Fri, 08 Sep 2000 09:35:56 +0000 |
| Subject: | Re: in_array() 4.0.0 -> 4.0.2 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15849@lists.php.net to get a copy of this message | ||
Thanks,
That will have to do. It seems like the best match.
I suppose is the closest thing to:
in_array("text",$myarray);
$item = key($myarray);
is
$i = array_keys("text",$myarray);
$item = $i[0];
David.
----- Original Message -----
From: Robin Vickery <robin@planet-three.co.uk>
To: <php-general@lists.php.net>
Sent: Friday, September 08, 2000 10:10 AM
Subject: Re: [PHP] in_array() 4.0.0 -> 4.0.2
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>