Last active
August 29, 2015 14:10
-
-
Save acfreitas/234a560b1ce261d9ade9 to your computer and use it in GitHub Desktop.
Int Random
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
/** | |
* @param int $size | |
* @return interger | |
*/ | |
public function intRandom($size) { | |
$validCharacters = utf8_decode("0123456789"); | |
$validCharNumber = strlen($validCharacters); | |
$int = ''; | |
while (strlen($int) < $size) { | |
$index = mt_rand(0, $validCharNumber - 1); | |
$int .= $validCharacters[$index]; | |
} | |
return $int; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment