PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

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:

What Are Arrays?
How To Create Arrays
How To View Arrays
How To Modify Arrays
Array arsort() Function
Array asort() Function
Array sort() Function
Array ksort() Function
Array krsort() Function
Array Echo
Array list() Function
Manual Array Iteration
Array count() & sizeof() Function




Home | Privacy Policy | Terms Of Use | Contact Us