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
  [EMAIL PROTECTED]



"Patrick Meisel" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
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




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to