Array difficulty

From: Date: Tue, 31 Jul 2007 13:27:46 +0000
Subject: Array difficulty
Groups: php.general 
Request: Send a blank email to php-general+get-259896@lists.php.net to get a copy of this message
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; } At this point, $result would be equal to "uppercase". I feel like this is a really kludgey way to accomplish this. Is there a better way? Regards, Carlton Whitehead

« previous php.general (#259896) next »