Does anybody have an idea how can I sort this array by key (date) in PHP?
Array
(
[2011-02-16] => Array
(
[date] => 2011-02-16
Well, as sorting on the key would do it, ksort() would work for you!
But if you really want to sort on the date element, you would use uasort() with a sort function like this
function compare($a, $b)
{
if ($a['date']==$b['date']) return 0;
return ($a['date']>$b['date'])?1:-1;
}
uasort($myarray, 'compare');