php: generate random number

function UniqueRandomNumbersWithinRange($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $quantity);
}

// $productsViewed = UniqueRandomNumbersWithinRange(1,500000,10);
// print_r($productsViewed);

Leave a Reply

Your email address will not be published. Required fields are marked *