I've used the manual page on mt_rand()
, but I just don't get how the example makes any sense, I guess this is two parts, what defines the min and max, if mt_rand(5,15)
can return 1604716014
I suppose its not limited between 5-15
. And how would I regex in some letters to make a password reset generator?
Thanks
Here's a little bit of script that I like to use to generate a random code
:
function generateCode( $charSeed ) { // you can use the username as $charSeed
$seed = "";
for ( $i = 1; $i <= 8; $i++ ) {
$seed .= substr( '0123456789abcdef', rand( 0, 15 ), 1 );
}
return md5( $seed . $charSeed ) . $seed;
}
You may have misread the documentation. mt_rand(5,15)
or rand(5,15)
will absolutely generate a random number between 5 and 15!