lundi 3 août 2015

Get random number with key

I need to get a random number with mt_srand and mt_rand but my code not work good i have many time the same number its not totaly random

$key = "8f49ba1f21a3d41b2ec7999dd1e246265d6d3f0ccf809695901d34c3b9152991";

$cr = substr($key, 0, 5);
mt_srand(crc32($cr));
$num[0] = mt_rand(1,50);

$cr = substr($key, 5, 10);
mt_srand(crc32($cr));
$num[1] = mt_rand(1,50);

$cr = substr($key, 10, 15);
mt_srand(crc32($cr));
$num[2] = mt_rand(1,50);

crc32 its good for mt_srand with alphanumeric key ? In local i work with windows 32bit and server is debian 7 64bit

Thanks




Aucun commentaire:

Enregistrer un commentaire