I have an array
$a = array(
"2010-05-03" =>100,
"2010-05-04" =>400,
"2008-05-01" =>800,
"2011-01-01" =>800
);
How do I find maximum and minimum by key( date)?
For example:
max => 2011-01-01
min => 2008-05-01
I would be lazy and just let PHP look twice over the array. Once to find the minimum and a second time to find the first matching key for that value:
Or for the maximum: