How do I reverse sort an array by key?
You guessed it... krsort - getting good at this PHP lark now!
Here's the obligatory quick example:
<?php
$myworld = array("a"=>"PHP","b"=>"learning","c"=>"I'm");
krsort($myworld);
print_r($myworld);
?>
Which confirms your suspicions:
Array
(
[c] => I'm
[b] => learning
[a] => PHP
)
More arrays PHP Questions
How do I add to the end of an array and know how large the array is?How do I remove the first element from an array?
How do I find out if a value is already in an array?
How can I reset an array in PHP?
How can I reverse sort an array keeping the correlation between the index and value?