PHP code to generate random Lotto numbers for Powerball

<?php

// Set the number of white balls and the range of numbers for the white balls
$numWhiteBalls = 5;
$whiteBallRange = range(1, 69);

// Set the number of red balls and the range of numbers for the red balls
$numRedBalls = 1;
$redBallRange = range(1, 26);

// Shuffle the white and red ball ranges
shuffle($whiteBallRange);
shuffle($redBallRange);

// Select the specified number of random white and red balls
$whiteBalls = array_slice($whiteBallRange, 0, $numWhiteBalls);
$redBalls = array_slice($redBallRange, 0, $numRedBalls);

// Sort the white balls in ascending order
sort($whiteBalls);

// Output the selected lotto numbers
echo "White balls: " . implode(", ", $whiteBalls) . "\n";
echo "Red balls: " . implode(", ", $redBalls) . "\n";

?>

This code uses the range() function to generate arrays of numbers for the white balls (1 to 69) and red balls (1 to 26), and then shuffles them using the shuffle() function. The code then uses the array_slice() function to select the specified number of random white and red balls from the shuffled arrays, and the sort() function to sort the white balls in ascending order. Finally, the code uses the implode() function to output the selected lotto numbers as a string.

Related Articles

- All From ChatGPT
PLG_GSPEECH_SPEECH_BLOCK_TITLE