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

Answer Posted / jude jeevanraj.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
)


Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me what types of loops exist in php?

565


How to access a Static Member of a Class in PHP?

511


What is the difference between runtime exception and compile time exception?

541


What is the difference between query and inquiry?

489


What is default session time in php?

518






How does php work?

532


What is the difference between print() and echo()?

573


How to protect special characters in query string?

530


Is age interval or ordinal data?

517


How to create a table to store files?

550


How cookies are transported from browsers to servers?

494


How to reset/destroy a cookie?

575


Tell me what is the main difference between require() and require_once()?

544


Which function is used to read a file removing the html and php tags in it upwork?

487


Tell me what is mean by an associative array?

519