Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
584 B
3
Indexable
Never
<?php


$numbers = [23, 12, 45, 9, 7, 8, 19, 22, 4, 1];
//          12, 23, 45, 9, 7, 8, 19, 22, 4, 1
//          9, 23, 45, 12, 7, 8, 19, 22, 4, 1
//          7, 23, 45, 12, 9, 8, 19, 22, 4, 1
//          4, 23, 45, 12, 9, 8, 19, 22, 7, 1
//          1, 23, 45, 12, 9, 8, 19, 22, 7, 4
// $numbers[0];

for($i = 0; $i < sizeof($numbers); $i++){
    for($j = 0; $j < sizeof($numbers); $j++){
        if($numbers[$j] > $numbers[$i]){

            $temp = $numbers[$i];
            $numbers[$i] = $numbers[$j];
            $numbers[$j] = $temp;
    
        }
    }
}

print_r($numbers);