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


Please Help Members By Posting Answers For Below Questions

Why php is widely used?

544


What are the methods of array in java?

487


How does html form submit work?

516


What are the encryption functions in php?

562


What are php strings?

532






What are the characteristics of php variables?

523


What does namespace mean in php?

552


What is crypt () in php?

488


armstrong number by using php while number is given by the keyboard.?

1693


What is the use of mysql_real_escape_string in php?

451


What is baseurl?

530


Which php framework is fastest?

506


What is csrf cookie?

481


How to call a php function from html button?

611


What is the difference between query and inquiry?

489