Last active
December 20, 2015 11:59
-
-
Save mannieschumpert/6127173 to your computer and use it in GitHub Desktop.
Generate a random number of a given length in PHP.
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 | |
// how long the string should be | |
$length = 8; | |
$num = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$num .= mt_rand(0, 9); | |
} | |
echo $num; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment