Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to sort associative arrays in descending order, according to the key in php ?

user-image
Question ajoutée par mohamed ahmed mahmoud , مصمم مواقع انترنت web designer , conect
Date de publication: 2017/04/02
medhatmahmoud mahmoud
par medhatmahmoud mahmoud , Web Designer , Connect Computer Service Co

<?php

 $names= array("Mohamed"=>"", "Ahmed"=>"", "Karem"=>"");

krsort($age);

?>

<?php

$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");

ksort($fruits);

foreach ($fruits as $key => $val) {  

  echo "$key = $val\\n";

}?>

The above example will output:

a = orange

b = banana

c = apple

d = lemon

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?