//冒泡排序 // $arr = array(12,45,89,3,24,55,223,76,22,11,89,2,4,5,28,112,20,434,23,65,65,765,6,8,23,5,33,553,45,423,64,77,84,23); $arr = array(100,800,200,300); $tmp; for($i=0;$i<count($arr)-1;$i++ ){ for($j=0;$j<count($arr)-1-$i;$j++){ if($arr[$j] > $arr[$j+1]){ $tmp = $arr[$j]; $arr[$j] = $arr[$j+1]; $arr[$j+1] = $tmp; } } } dump($arr);die;