Multi-demension arrays always get me... I need help sorting this array two ways.
Array
(
[1] => Array
(
[timestamp] => 1153408578
)
[2] => Array
(
[timestamp] => 1153408589
)
[3] => Array
(
[timestamp] => 1153408592
)
[2.txt] => Array
(
[timestamp] => 1153408593
)
[3.txt] => Array
(
[timestamp] => 1153408593
)
)
#1 : I would like to sort the array by the key, maintaining the inside array. I tried ksort, but it did not appear to work.
#2 : I would like to sort the array the array but the timestamp, maintaining the associations.
Thanks
For #2, we'll extract the timestamps in order, and then pass that as the first parameter to array_multisort, and your multi-d array as the second..
$reference = array();
foreach ($yourArray as $row)
$reference[] = $row['timestamp'];
array_multisort($reference