Skip to content

arsort ​

php
bool arsort ( array &$tablica )

Sorts $tablica from highest to lowest value, preserving the keys associated with the values. Returns true if sorting succeeds.

Example:

php
$owoce = array();
$owoce["d"] = "lemon";
$owoce["a"] = "orange";
$owoce["b"] = "banana";
$owoce["c"] = "pineapple";

arsort($owoce);
print_r($owoce);

Result:

Array
(
    [c] => pineapple
    [a] => orange
    [d] => lemon
    [b] => banana
)