Re: Array difficulty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 31/07/07, Carlton Whitehead <carlton.whitehead@xxxxxxxxxxxx> wrote:
> Hi all,
>
> I have an array like this:
>
> $chance = array("lowercase" => 27, "uppercase" => 62, "integer" => 46);
>
> The values for each of the keys are randomly generated. I want to find the key name of the one which has the highest value. Currently, I'm doing this as follows:
>
> arsort($chance);
> foreach ($chance as $type => $value)
> {
>         $result = $type;
>         break;
> }
>

Assuming $chance is non-empty.

$result = array_search(max($chance), $chance);

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux