php计算大乐透彩票算法

        //随机5注
        for($j=1;$j<=5;$j++)
        {
            //取前区号码 1-35随机5个数字
            for($i=1;$i<=35;$i++){
                $num=$i;
                if($i<=9)
                {
                    $num='0'.$i;
                }
                $arr[$i]=$num;
                shuffle($arr);
                $arr=array_unique($arr);
                $return_before=array_slice($arr,0,5);
            }
            //取后区号码 1-12随机2个数字
            $return_before=implode(',',$return_before);
            $chars = ['01','02','03','04','05','06','07','08','09','10','11','12'];//后区
            shuffle($chars);
            $return_after=array_slice($chars,0,2);
            $str='';
            $str.=$return_before.' '.implode(',',$return_after).'</br>';//组合数据
            print_r($str);
        }

效果图:

猜你喜欢

转载自www.cnblogs.com/langzibht/p/10058933.html