Created
March 12, 2013 00:51
-
-
Save schleumer/5139373 to your computer and use it in GitHub Desktop.
Generate an array with $quantity random numbers from the given range (from $x to $y)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate an array with $quantity random numbers from the given range (from $x to $y) | |
* @param int $min | |
* @param int $max | |
* @param int $quantity | |
* @return array | |
*/ | |
function generateNumbers($min, $max, $quantity) { | |
$array = range($min, $max); | |
for ($x = 0; $x <= $quantity; $x++) { | |
unset($array[array_rand($array)]); | |
} | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment