Use mt_rand over rand, when repeatedly calling in quick succession.

When calling rand() in a loop, you don't actually get much randomness.  It would be better to call mt_rand() in this situation.

I hope this helps.