This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Arrays

Sorting numerical Array in ascending order

2
4
6
11
22

<?php
// define the array $numbers
$numbers = array(4, 6, 2, 22, 11);

// sort the array in ascending order
sort($numbers);

// display the array items in ascending order
$arrlength = count($numbers);
for($x = 0; $x < $arrlength; $x++) {
  echo $numbers[$x];
  echo "<br>";
}
?>