On Mon, Jun 8, 2009 at 5:29 PM, tedd<t...@sperling.com> wrote:
> Hi gang:
>
> Does anyone have a slick way to determine what the key would be for a
> successful find in in_array()?
>
> Such as:
>
> if (in_array($var, $array))
>   {
>   // what's they key for *this* successful find?
>   }
>
> I know I could use:
>
> foreach($array as $key => $value)
>   {
>   if ($value == $var)
>     {
>      // then I know what the key would be.
>     }
>   }
>
> But is there a simpler way using in_array()?
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>

Try this instead:

http://us3.php.net/manual/en/function.array-search.php

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to