PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I reverse sort the members of an array?


If you wish to reverse sort the members of an array by their values, then you need to use rsort, for reverse sort, instead of sort.

Again this takes the name of the array as its parameter and here's a little example for you:

<?php
$myworld 
= array("it","better","make","you");
rsort($myworld);
print_r($myworld);
?>


printing to the screen:

Array
(
[0] => you
[1] => make
[2] => it
[3] => better
)



More arrays PHP Questions

I want to invert my array, can I do this?
How do you remove duplicate values from an array?
How can I sort an array keeping the correlation between the index and value?
How do I count the number of times a value appears in an array?
How do I reverse sort an array by key?