HS Banner
Back
Unique Random Numbers Within a Range

Author: Admin 04/23/2023
Language: PHP
Views: 194
Tags: random numbers range php


Description:

Here's a nice function I found to get 10 unique numbers from a range of numbers.

Article:

//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));



Back
Comments
Add Comment
There are no comments yet.