Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i-Clyde/cbea0085cef71cf832f42b5ae648a7a5 to your computer and use it in GitHub Desktop.
Save i-Clyde/cbea0085cef71cf832f42b5ae648a7a5 to your computer and use it in GitHub Desktop.
// $nrs = range($from,$to) - There you can set the compartment of your numbers e.g. range(10,992);
// $from == which number will be the lowest possibility
// $to == which number will be the highest possibility
// $scope == how many numbers from ($from,$to) will be displayed
function rnum($scope) {
$nrs = range(1,70);
$nr = array_rand($nrs,$scope);
shuffle($nr);
for ($i=0;$i<=$ilosc-1;$i=$i+1) {
if($i==0) $liczby = $nrs[$nr[$i]];
else $liczby = $liczby.";".$nrs[$nr[$i]];
} return($liczby);
}
//Display the random numbers
$numbers = explode(";",rnum(5)); //Explode the numbers to get an array
echo $numbers[0]."<br>"; // Display the generated numbers
echo $numbers[1]."<br>";
echo $numbers[2]."<br>";
echo $numbers[3]."<br>";
echo $numbers[4]."<br>";
//!Warning the $scope can't be highter than the difference between $from,$to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment