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

What is the main difference between php 4 and php 5?

725


Explain how can we increase the execution time of a php script?

706


What is the function mysql_pconnect() useful for?

715


Why do we need session?

711


Is PHP runs on different platforms (Windows, Linux, Unix, etc.)?

716


What is the difference between == and === in php?

743


Which array function checks if the particular key exists in the array?

678


What type of operation is needed when passing values through a form or an url?

725


How do I use isdigit function?

762


How do I check if a given variable is empty?

695


How do you destroy a particular or all Sessions?

765


Is strcmp case sensitive?

713


What is the php function that removes the last element of the array and returns it?

697


Why use php artisan serve?

677


What is difference between static and constant in php?

695