fork(1) download
  1. <?php
  2.  
  3. $num_rand_values = 5;
  4.  
  5. for($i = 0; $i < $num_rand_values; $i++)
  6. $array[] = mt_rand(0,9);
  7.  
  8. echo "Unsorted array is: ";
  9. echo "<br />";
  10. print_r($array);
  11.  
  12. sort($array, SORT_NUMERIC);
  13.  
  14. print_r($array);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Unsorted array is: <br />Array
(
    [0] => 5
    [1] => 0
    [2] => 1
    [3] => 9
    [4] => 6
)
Array
(
    [0] => 0
    [1] => 1
    [2] => 5
    [3] => 6
    [4] => 9
)