The Mersenne Twister algorithm is a deterministic algorithm. It starts with a seed and then generates random numbers based on this. Thus, if the seed is the same, it will generate the same random numbers.
Usually PHP seeds mt_randwith some data are based microtime, but you can manually use their seeds with mt_srand.
mt_srand(0);
var_dump(mt_rand());
mt_srand(0);
var_dump(mt_rand());
Note that both function calls will have the same number 963932192.
So, all you basically need to do is seed manually, and you can predict all the numbers that it generates.
NikiC source
share