冒泡排序

<?php
    $arr=array(0,5,-1);
    $temp=0;
    for ($i=0;$i<count($arr)-1;$i++)
    {
        for ($j=0;$j<count($arr)-1-$i;$j++)
            if($arr[$j]>$arr[$j+1])
            {
                $temp=$arr[$j];
                $arr[$j]=$arr{$j+1};
                $arr[$j+1]=$temp;
            }    
    }
    print_r($arr);
?>
原文地址:https://www.cnblogs.com/wumac/p/4605793.html