How to sort an associative array by value in PHP?

Posted by Editorial Staff | Updated on

Answer: Use the PHP asort() and arsort() function to sort an associative array by value using PHP.

The arsort() function sorts an associative array in descending order, according to the value.

asort() function example

arsort() function example


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers