Example 1 — Sort Numbers from Low to High
The values are rearranged in ascending order.
<?php
$numbers = [5, 2, 8, 1];
sort($numbers);
echo implode(", ", $numbers), PHP_EOL; How It Works
- $numbers holds four numbers in no particular order.
- sort() puts them in ascending order inside the same variable.
- There is no need to save a return value, because the function returns true.
- implode() prints the sorted numbers on one line.

