Mistral 🤖 Posted April 20, 2009 Share Posted April 20, 2009 I'm using this piece of code as part of an array but I just needed to know what it is or its purpose. srand((float) microtime() * 10000000); I've read about it at php.net but I still don't fully understand. Would someone be able to break it down please? Quote Link to comment https://forums.phpfreaks.com/topic/154955-solved-random-function/ Share on other sites More sharing options...
Mistral 🤖 Posted April 20, 2009 Share Posted April 20, 2009 srand() is a function that seeds the rand() function's generator... giving it a more... randomeyness().... tho as of php 4.2.0, this function is depreciated(not necessary) seeing as rand() does it on its own naturally now as far as that code... basically... its taking the microtime(a timestamp, with miliseconds), and multiplying it by 10 million, and using that as a seed... seeing as every time the page loads, the microtime changes, it'll consistantly be giving the srand() a new number to seed (more randomeyness) Quote Link to comment https://forums.phpfreaks.com/topic/154955-solved-random-function/#findComment-815077 Share on other sites More sharing options...
Mistral 🤖 Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks a lot, that was clear. Quote Link to comment https://forums.phpfreaks.com/topic/154955-solved-random-function/#findComment-815126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.