SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Reverse Sort using rsort

We can sort an array in reverse order of sort function by using rsort command. Here the index associated with each element is not retained. This is the only difference between rsort and arsort commands.




Here is the example code.









<?
$input = array ("Pinaple", "Orange", "Banana", "Mango", "Apple","Strawberry");
while (list ($key, $val) = each ($input)) {
echo "$key -> $val <br>";
}
rsort($input);
echo "<br>-----After rsort---------<br>";
while (list ($key, $val) = each ($input)) {
echo "$key -> $val <br>";
}
?>


Here is the output of rsort function

 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Array Functions
array_diff
array_count_values
array_size
array_push
array_sum
in_array
array_rand
array_unique
Split String
unset (delete)
sort
rsort
asort
arsort
ksort
krsort
usort
Displaying elements
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.