Re: [PHP] Array difficulty
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);
.
Relevant Pages
- Re: comparing some but not all fields in lists
... and what's in common." ... I should compare only 3 of the 82 fields in each list. ... comparing all 82 fields as a single array element. ... cannot handle multiple keys as you want it to. ... (perl.beginners) - Re: Build an array from a text file
... Now that I have created my array, ... The dictionary object has a 'keys' method that returns a 0 based array ... Dim vArray As Variant ... dictionaries, so any help would be great! ... (microsoft.public.word.vba.general) - Re: Nugget - Using control references
... until someone decides they want to save a 3D array. ... If the users are likely to add elements to the middle of the enum, you should save and load by the enum text. ... What you can try is this - save both the string and the number. ... Unused keys are not deleted. When the number of elements in an array is reduced, the key entries still exist in the file. ... (comp.lang.labview) - Re: hash sortieren nach werten, hash in =?ISO-8859-15?Q?popupmen?= =?ISO-8859-15?Q?=
... Dieses Array gibst Du bei -values an. ... Du schreibst Dir eine Funktion, die Dir die Keys ... des Hashes in der Sortierung der Werte liefert. ... values ist eine Referenz auf ein @rray, ... (de.comp.lang.perl.cgi) - Re: populating a hash with % used as the key and F string as the value
... > keys %lookup; ... it states one cannot push or pop a hash on page 10 ... itself is the reference to the array (read: an arrayref). ... (perl.beginners) |
|