- print_r: documentation ( source)
<?php
$str = [54,23,2,56,7,2,300];
$count = count($str);for ($j = 0; $j < $count; $j++) {
for ($i = $j + 1; $i < $count; $i++) {
//if ($str[$i] > $str[$j]) {
// list($str[$i], $str[$j]) = [$str[$j], $str[$i]];
//}
if ($str[$i] < $str[$j]) {
list($str[$i], $str[$j]) = [$str[$j], $str[$i]];
}
}
}
print_r($str);