在第二个for循环中,为什么要$j>$i
<?php
function bubble_sort($array)
{
$count = count($array);
if ($count <= 0) return false;
for($i=0; $i<$count; $i++){
       for($j=$count-1; $j>$i; $j--){
         if ($array[$j] < $array[$j-1]){
            $tmp = $array[$j];
            $array[$j] = $array[$j-1];
            $array[$j-1] = $tmp;
         }
       }
}
return $array;
}$str = array(3,6,1,5,9,0,4,6,7);
print_r(bubble_Sort($str));
echo count($str);
?>