arsort() function maintains the original index association and sorts the elements in reverse order. : arsort « Data Structure « PHP






arsort() function maintains the original index association and sorts the elements in reverse order.

 
Its syntax is: void arsort (array array)

<?
    $cities = array ("A" => "a",
            "I" => "i",
            "A" => "z",
            "F" => "f",
            "C" => "c");

    arsort($cities);
    for (reset ($cities); $key = key ($cities); next ($cities)) :
         print "cities[$key] = $cities[$key] <br>";
    endfor;
?>
  
  








Related examples in the same category

1.Reversing an Array Using arsort()
2.arsort( ) function reverse sorts it by its values while preserving the keys
3.Sorting with arsort()