Re: Sorting an assoiative Array

From: Date: Mon, 09 Jul 2001 15:01:39 +0000
Subject: Re: Sorting an assoiative Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56938@lists.php.net to get a copy of this message
I used similar and just put it into a function function array_max($array) { asort($array); return current($array); } this just gives me the first element of the array. -- Chris Lee lee@mediawaveonline.com "Patrick Meisel" <patrick@karlshof.de> wrote in message news:5.1.0.14.0.20010709020001.00a30ec0@130.83.63.70... Hi, I need to get the highest value of a hash. I first just wanted to do an arsort and then access the first value with $data[0], which didn´t work. I guess you can´t access associative arrays by index. So I found this way to do it (as the $data array needs to remain unchanged): $temp=$data; arsort ($temp); $max=reset($temp); Is there really no shorter way to do it?? Pat

« previous php.general (#56938) next »