Forum : How can I reverse sort an array keeping the correlation between the index and value?
Brief description  about Online courses   join in Online courses
View  's Profile

How can I reverse sort an array keeping the correlation between the index and value?

Hi,

Can any one tell me how to to reverse sort an array keeping the correlation between the index and value?
Asked by | Nov 27, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Naveen P,

This is done using the arsort function:

<?php
$myworld = array("a"=>"everything","b"=>"nothing","c"=>"is");
arsort($myworld);
print_r($myworld);
?>

Which prints this:

Array
(
[b] => nothing
[c] => is
[a] => everything
)
Nov 27, 2009