|
| SORTING ARRAYS WITH THE rsort() FUNCTION
The rsort() function sorts an array's values in reverse order. Assigns new keys and replaces text keys with new number keys.
The general format for the rsort() function is:
rsort($array);
This sorts the array by value, sorted by lowercase letters first descending , then uppercase letters descending and lastly numbers descending.
Example:
$username['John']="Elmafudd";
$username['Alieza']="8hotchick";
$username['Brian']="aopper24";
$username['Mary']="11_daper";
rsort($username);
The array is now.
$username[0] = aopper24
$username[1] = Elmafudd
$username[2] = 8hotchick
$username[3] = 11_daper
To sort arrays in reverse order and retain the original keys, use the arsort() function instead.
See also:
|
|