Sorts an array in descending order.
The rsort() function sorts an array in descending order. Except for the ordering, rsort() works just like sort(). Any keys in the array will be lost. The optional sort_type parameter specifies whether the elements should be sorted as strings or numerically. If the array was sorted successfully, TRUE is returned.
<?php
function elementPrint($value)
{
print "$value ";
}
$array1 = array(34, 75, 23, 68, 54, 91, 24, 12);
$array2 = array("orange", "banana", "apple", "plum", "pear");
rsort($array1);
array_walk($array1, "elementPrint");
print "<br>";
rsort($array2);
array_walk($array2, "elementPrint");
?>
91 75 68 54 34 24 23 12
plum pear orange banana apple
A numeric and a string array are sorted in reverse order.