sort() function
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
<?php $array = array ( 4, 8, - 1, - 9, 2, 5, 3, - 4 ); var_dump ( $array ); // displaying array without sorting sort ( $array ); // Sorting echo "<br />"; var_dump ( $array ); // displaying array after sorting ?>
Output :
array 0 => int 4 1 => int 8 2 => int -1 3 => int -9 4 => int 2 5 => int 5 6 => int 3 7 => int -4 array 0 => int -9 1 => int -4 2 => int -1 3 => int 2 4 => int 3 5 => int 4 6 => int 5 7 => int 8