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 strstr php?
What are the two main string operators?
What is the difference between unset and unlink?
Are react hooks stable?
How to concatenate two strings in php?
Is age an interval or ratio?
Where is the submitted form data stored?
Is php object oriented?
What is use of header() function in php? What the limitation of header()?
How to fix "headers already sent" error in php
Who is the father or inventor of php?
Who developed php?
What is the difference between html and php?
How is session data stored?
Write a program in php to reverse a number?