PHP asort() FunctionLast Updated : 17 Mar 2025 The asort( ) function is an inbuilt function of PHP. The asort( ) function is used to sort an associative array in ascending order, according to the value. This function was introduced in PHP 4.0. SyntaxParameters
ReturnIt returns true on success or false on failure. Example 1Output:
Array
(
[virat] => 29
[ganguly] => 39
[sachin] => 42
)
Example 2Output:
Array
(
[G] => Black
[W] => Cyan
[Y] => Green
[B] => White
[C] => Yellow
)
Example 3Output:
Array
(
[compiler] => 68
[data structure] => 89
[OS] => 95
)
Example 4Output:
Array
(
[b] => Geography
[d] => Hindi
[c] => Math
[a] => Science
)
Next TopicPhp-array-changekeycase-function |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India