<?php
//冒泡排序
function bebbleSort($num){
$cnt = count($num);
for($i=0;$i<$cnt-1;$i++){
for($j=0;$j<$cnt-$i-1;$j++){
if($num[$j]>$num[$j+1]){
$temp = $num[$j];
$num[$j] = $num[$j+1];
$num[$j+1] = $temp;
}
}
}
return $num;
}
$data = [5,3,10,2,1,12];
echo "<pre>";
var_dump(bebbleSort($data));