PHPize Online / SQLize Online

Donate Popular

arsort

Tags: PHP 5.x PHP 7.x PHP 8.x

arsort — Sort an array in descending order and maintain index association.

Description

arsort(
    array &$array,
int $flags = SORT_REGULAR
): bool
Sorts array in place in descending order, such that its keys maintain their correlation with the values they are associated with.
This is used mainly when sorting associative arrays where the actual element order is significant.

Note: If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.

Parameters

array
The input array.
flags
The optional second parameter flags.

Return Values

Always returns true.