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
)
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
How can I reset an array in PHP?how sorting an array with keys?
How can I loop through the members of an array?
reverse an array
how a values entered in an array from keyboard?
