PHP Array Functions

sort() Function

Definition and Usage

The sort() function sorts an indexed array in ascending order.


Syntax

sort(array)


Parameter Description
array Required. Specifies the array to use

Example

Sort the elements of the $numbers array in ascending numerical order:

<?php
$numbers=array(4,6,2,22,11);
sort($numbers);
?>

Run Example>>