How can I sort a multi-dimensional array in a reverse order?
For instance,
Code: Select all
$songs = array(
'3' => array('artist'=>'The Smashing Pumpkins', 'songname'=>'Soma'),
'4' => array('artist'=>'The Decemberists', 'songname'=>'The Island'),
'1' => array('artist'=>'Fleetwood Mac', 'songname' =>'Second-hand News'),
'2' => array('artist'=>'Jack Johnon', 'songname' =>'Only the Ocean')
);
print_r($songs);Code: Select all
Array
(
[3] => Array
(
[artist] => The Smashing Pumpkins
[songname] => Soma
)
[4] => Array
(
[artist] => The Decemberists
[songname] => The Island
)
[1] => Array
(
[artist] => Fleetwood Mac
[songname] => Second-hand News
)
[2] => Array
(
[artist] => Jack Johnon
[songname] => Only the Ocean
)
)Code: Select all
Array
(
[2] => Array
(
[artist] => Jack Johnon
[songname] => Only the Ocean
)
[1] => Array
(
[artist] => Fleetwood Mac
[songname] => Second-hand News
)
[4] => Array
(
[artist] => The Decemberists
[songname] => The Island
)
[3] => Array
(
[artist] => The Smashing Pumpkins
[songname] => Soma
)
)do I need to write a function to do this?
Many thanks,
Lau