<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
The above example will output:
a = orange
d = lemon
b = banana
c = apple
The fruits have been sorted in reverse alphabetical order, and
the index associated with each element has been maintained.