The krsort function sorts an array by key in descending order.
$capitals = array('New York' => 'Albany', 'Texas' => 'Austin', 'Florida' => 'Tallahassee');
krsort($capitals);
print_r($capitals);
// Array (
// [Texas] => Austin
// [New York] => Albany
// [Florida] => Tallahassee
//)