Skip to content

Instantly share code, notes, and snippets.

@thistehneisen
Created December 15, 2020 13:15
Show Gist options
  • Save thistehneisen/50579a0dd6f396f0aec2eed1d49d1a9c to your computer and use it in GitHub Desktop.
Save thistehneisen/50579a0dd6f396f0aec2eed1d49d1a9c to your computer and use it in GitHub Desktop.
Lottery Number Generator (6/49) - generate 6 random numbers in the range 1 - 49 inclusive
<?php
function lottery649($maxn = "49",$maxb="6") {
srand((double)microtime() * 1000000);
while (1>0) {
$lottery[] = rand(1,$maxn);
$lottery = array_unique($lottery);
if (sizeof($lottery) == $maxb) break;
}
sort($lottery);
return implode(", ",$lottery);
}
$lottery649 = lottery649();
print($lottery649);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment