Author: Admin 04/23/2023
Language:
PHP
Tags: random numbers range php
Here's a nice function I found to get 10 unique numbers from a range of numbers.
//Unique Number function
function UniqueRandomNumbersWithinRange($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $quantity);
}
//Show results
print_r(UniqueRandomNumbersWithinRange(1,1000,10));