Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is namespace in php?

1030


What is implode() in php?

1091


Which function you can use in php to open a file for reading or writing or for both?

1099


Tell me how can you pass a variable by reference?

962


Do you know what is the use of rand() in php?

988


Can we override magic methods in php?

1022


Is php easier than node?

940


What is smarty?

972


How can we create a database using php?

1127


How to Retrieve the Session ID of the Current Session?

984


What is super keyword in c++?

1007


What is the meaning of symbol '$' in jquery?

1067


Is empty function c++?

972


What is the use of 'print' in php?

1021


Explain how we can get the number of elements in an array?

1047