You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
388 B

<?php
$arr=array(54,7,6,32,45,80,62,211,583);
for ($j=0; $j < count($arr) ; $j++){
for ($i=0; $i < count($arr) - 1 - $j; $i++)
{
if($arr[$i] > $arr[$i+1])
{
$tmp = $arr[$i+1];
$arr[$i+1] = $arr[$i];
$arr[$i] = $tmp;
}
}
}
echo '<pre>';
print_r($arr);
?>