Sort associative array in descending order in PHP according to Key

How to use krsort() method in php scripting language.

android-project-download-code-button
Code for sort-array-descending-accordingKey.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sort associative array in descending order in PHP according to Key</title>
</head>

<body>

<?php
$name = array("Ram"=>"89", "Shyam"=>"88", "Anil"=>"86");
krsort($name);

foreach($name as $a => $a_value) {
 
 echo "Key=" . $a . ", Value=" . $a_value . '</br>';
 
}
?>

</body>
</html>

Screenshot:

Sort associative array in descending order in PHP according to Key

Click here to download Sort associative array in descending order in PHP according to Key project file.

Leave a Reply

Your email address will not be published. Required fields are marked *