$arr=array(1,43,54,62,21,66,32,78,36,76,39,2);
function bubbleSort ($arr)
{
$len = count($arr);
for ($i=1; $i<$len; $i++) {
for ($k=0; $k<$len-$i; $k++) {
if($arr[$k] > $arr[$k+1]) {
$tmp = $arr[$k+1];
$arr[$k+1] = $arr[$k];
$arr[$k] = $tmp;
}
}
}
return $arr;
}
var_dump(bubbleSort($arr));