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
Sure thing. I answered this exact post yesterday, too.
Sorting 2 arrays to get the highest in one and lowest in another
In your case, it will be something like...
$myArray= subval_sort($myArray,'date');
function subval_sort($a,$subkey) {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
asort($b);
foreach($b as $key=>$val){
$c[] = $a[$key];
}
return $c;
}
EDIT
The answer by shamittomar is better though :)