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 namespace in php?
What is implode() in php?
Which function you can use in php to open a file for reading or writing or for both?
Tell me how can you pass a variable by reference?
Do you know what is the use of rand() in php?
Can we override magic methods in php?
Is php easier than node?
What is smarty?
How can we create a database using php?
How to Retrieve the Session ID of the Current Session?
What is super keyword in c++?
What is the meaning of symbol '$' in jquery?
Is empty function c++?
What is the use of 'print' in php?
Explain how we can get the number of elements in an array?