Sort an array in reverse order and maintain index association
<? $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); arsort ($fruits); for (reset ($fruits); $key = key ($fruits); next ($fruits)) { echo "fruits[$key] = ".$fruits[$key]."\n"; } ?>