//递归算法举例
function digui($num = 0,$sum = 0) {
if(empty($num)){
return $sum;
}
$sum = $sum + $num + ($num - 1);
return digui($num - 2, $sum);
}
echo digui(1000);
//排序算法举例
function maopao($arr){
if(empty($arr)){
return $arr;
}
for ($i = 0; $i < count($arr); $i++){
for($j = 0; $j < (count($arr) - 1); $j++){
if($arr[$j] > $arr[$j+1]){
$temp = $arr[$j];
$arr[$j] = $arr[$j+1];
$arr[$j+1] = $temp;
}
}
}
return $arr;
}
$arr = array(4,7,3,5,9,1,10,2,8,6);
echo "<pre>";
print_r(maopao($arr));