PHP sort() FunctionLast Updated : 17 Mar 2025 The PHP sort( ) function is used to sort the array elements in ascending order. This function was introduced in PHP 4.0. SyntaxParameter
ReturnsThe sort( ) function returns true on success or false on failure. Example 1Output:
Array
(
[0] => acoustic
[1] => classical
[2] => electric
)
Example 2Output:
Array
(
[0] =>audi
[1] =>bmw
[2] =>nissan
)
Example 3Output:
Array
(
[0] => 400
[1] => 100
[2] => 50
[3] => 20
[4] => 1
)
Array
(
[0] => 1
[1] => 20
[2] => 50
[3] => 100
[4] => 400
)
Example 4Output:
Array
(
[0] => compiler
[1] =>dbms
[2] => networking
[3] =>os
)
Next TopicPhp-array-splice-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