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
How to randomly retrieve a value from an array?
What is framework in php?
What is repository in php?
How to pass variables and data from php to javascript?
What are the array functions in php?
How long is csrf token?
Does mysql need php?
Write a program to find a string is palindrome or not?
What are the advantages of oops in php?
How to assigning a new character in a string?
Explain what are psrs?
Is php required for wordpress?
Can I include php in javascript?
Tools used for drawing er diagrams?
What is $_ get and $_ post in php?