标签:
<?php
$array = array(11,-3,51,-7,9,100,2,-56,32,21);
$flag = false;
for ($i = 1;$i < count($array);$i++){
for ($j = 0;$j < count($array) - $i;$j++){
if ($array[$j] > $array[$j + 1]){
$temp = $array[$j];
$array[$j] = $array[$j + 1];
$array[$j + 1] = $temp;
$flag = true;
}
}
if (!$flag){
break;
}
$flag = false;
}
foreach ($array as $value){
echo $value.‘  ‘;
}
?>
标签:
原文地址:http://my.oschina.net/zhengyp/blog/490792