Search Results
arsort (PHP 4, PHP 5, PHP 7, PHP 8) arsort — Sort an array in descending order and maintain index association
The arsort () function sorts an associative array in descending order, according to the value. Tip: Use the asort () function to sort an associative array in ascending order, according to the value.
Jul 11, 2025 · Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.
PHP arsort () Function Topic: PHP Array Reference Prev | Next Description The arsort() function sorts an associative array in descending order, according to the value. The keys are preserved, i.e. the key-to-value mapping will remain unchanged by the sort operation. The following table summarizes the technical details of this function.
- Returns TRUE on success or FALSE on failure.
- PHP 4+
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. It returns TRUE on success or FALSE on failure. Try out following example − This will produce the following result −
Dec 31, 2023 · PHP arsort () function: In this tutorial, we will learn about the PHP arsort () function with its usage, syntax, parameters, return value, and examples.
People also ask
What is arsort() function?
What is the difference between arsort() and krsort() functions?
Does arsort return a sorted array?
How to sort an associative array in descending order in PHP?
Aug 19, 2022 · The arsort() function sorts an array in reverse order and maintain index association.
