
-
<?
//冒泡排序法function bubble_sore($array) {
$count = count($array);
if ($count < 0) {
return false;
}
for ($i = 0; $i < $count-1; $i++) {
for ($j = 0; $j < $count - $i -1;$j++) {
if ($array[$j] < $array[$j+1]) {
$temp = $array[$j+1];
$array[$j+1] = $array[$j];
$array[$j] = $temp;
}
}
}
return $array;
}
$arr = array(1,9,8,5);
$re = bubble_sore($arr);
var_dump($re);?>