<?php
$array = [2, 5, 7, 99, 90, 42, 88, 8, 9, 0, 56];
$count = count($array);
for($i = 0; $i < $count; $i++){
for($j = 0; $j < $count-1; $j++){
if($array[$j] < $array[$j+1]){
$temp = $array[$j+1];
$array[$j+1]= $array[$j];
$array[$j] = $temp;
}
}
}
for($k = 0; $k < $count; $k++){
echo $array[$k] . '<br>';
}
$array = [2, 5, 7, 99, 90, 42, 88, 8, 9, 0, 56];
$count = count($array);
for($i = 0; $i < $count; $i++){
for($j = 0; $j < $count-1; $j++){
if($array[$j] < $array[$j+1]){
$temp = $array[$j+1];
$array[$j+1]= $array[$j];
$array[$j] = $temp;
}
}
}
for($k = 0; $k < $count; $k++){
echo $array[$k] . '<br>';
}
No comments:
Post a Comment