How can I reverse sort an array keeping the correlation
between the index and value?
Answer Posted / amit
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" =>
"banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
OUTPUT
a = orange
d = lemon
b = banana
c = apple
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is a http session?
How can we destroy the cookie in php?
Which php framework is best?
What are the differences between GET and POST methods?
Tell me is it possible to protect special characters in a query string?
How many keywords are there in php?
Is null check in php?
How to remove an empty directory?
Explain the difference between php4 and php5.
What are the difference between abstract class and interface in oops?
What are php magic methods/functions?
Explain a resource?
What are the delimiters in php?
How to select a database in php?
Which library is used in php to do various types of image work?