PHP代码来模拟双色球,大乐透机选

//双色球:红球1-33选6个 蓝球 1-16选一个
$Double_red_array = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33'];
$Double_blue_array = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16'];

$Double_result='双色球:';
$The_Double_red=array();
$The_ball=array_rand($Double_red_array,6);
foreach($The_ball as $v){
    $The_ball_str[]=$Double_red_array[$v];
}
$Double_result=$Double_result.implode(' ',$The_ball_str);
$The_blue=array_rand($Double_blue_array,1);
$Double_result=$Double_result.' - '.$Double_blue_array[$The_blue];


//大乐透:前区1-35选5个 后区 1-12选2个
$lotto_front=['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33','34','35'];
$lotto_after=['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
$lotto_result='大乐透:';
$The_front_ball=array_rand($lotto_front,5);
foreach($The_front_ball as $v){
    $The_front_ball_str[]=$lotto_front[$v];
}
$lotto_result=$lotto_result.implode(' ',$The_front_ball_str);
$The_after_ball=array_rand($lotto_after,2);
foreach($The_after_ball as $v){
    $The_after_ball_str[]=$lotto_after[$v];
}
$lotto_result=$lotto_result.' + '.implode(' ',$The_after_ball_str);

$str= '时间:'.date('Y-m-d H:i:s',time()).'
'
.$Double_result.'
'
.$lotto_result; $html='
'.$str.'
'
; echo $html;

运行结果:
时间:2019-11-12 15:15:45
双色球:17 23 27 28 29 31 - 10
大乐透:03 05 09 22 35 + 03 11

此代码仅供娱乐

你可能感兴趣的:(PHP)