$assocarray = array('a' => 1, 'b' => 2, 'c' => 3); $keys = array_keys($assocarray); rsort($keys); while (!empty($keys)) {     $key = array_pop($keys);     echo $key . ' = ' . $assocarray[$key] . '<br />'; }; 

Read more of this post