Sort associative array in descending order in PHP according to value

How to use arsort() array method in php programming language.

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

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

<body>

<?php
$name = array("Ram"=>"89", "Shyam"=>"88", "Anil"=>"86");
arsort($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 value

Click here to download Sort associative array in descending order in PHP according to value project file with source code.

Leave a Reply

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