rsort and arsort

rsort and arsort

Basically both the functions are used to sort an array

But the differnce is arsort will maintain keys after sorting has performed, rsort won’t maintain keys.

Example
$arr = array(”one”=>1,”two”=>2,”three”=>3);
rsort($arr);
print_r($arr);

It will produce the folowing result
Array ( [0] => 3 [1] => 2 [2] => 1 )

$arr = array(”one”=>1,”two”=>2,”three”=>3);
rsort($arr);
print_r($arr);

It will produce the folowing result
Array ( [three] => 3 [two] => 2 [one] => 1 )

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.