php冒泡

function bunble($array)
{
    for($i=0;$i < count($array)-1;$i++)
    {
        for($j=0;$j $array[$j+1])
            {
                $tmp = $array[$j];
                $array[$j] = $array[$j+1];
                $array[$j+1] = $tmp;
            }
        }
    }
    return $array;
}

$array = array(3,5,9,43,4,13,11);
print_r(bunble($array));
?>

你可能感兴趣的:(php冒泡)