Sort Array (Descending Order), According to Key – krsort()

The following example sorts an associative array in descending order, according to the key:

<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
krsort($age);
?>
Scroll to Top