<?php
$a = [1,3,5,2,9,6];
for ($i = 0 ;$i < count($a) ;$i++) {
for ($j = $i + 1;$j < count($a) ; $j ++) {
if ($a[$i] > $a[$j]) {
$tmp = $a[$i];
$a[$i] = $a[$j];
$a[$j] = $tmp;
}
}
}
print_r($a);
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 5
[4] => 6
[5] => 9
)