3raser Posted March 10, 2011 Share Posted March 10, 2011 How do you generate a random number like say, 0 through 10? I want to select random sites from my database that have IDs 0 through 10. Quote Link to comment https://forums.phpfreaks.com/topic/230169-generate-random-numbers/ Share on other sites More sharing options...
cyberRobot Posted March 10, 2011 Share Posted March 10, 2011 rand() should work: http://php.net/manual/en/function.rand.php Quote Link to comment https://forums.phpfreaks.com/topic/230169-generate-random-numbers/#findComment-1185346 Share on other sites More sharing options...
devWhiz Posted March 10, 2011 Share Posted March 10, 2011 ".rand(1,10)." Quote Link to comment https://forums.phpfreaks.com/topic/230169-generate-random-numbers/#findComment-1185355 Share on other sites More sharing options...
3raser Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks guys, much appreciated for the quick replies. Quote Link to comment https://forums.phpfreaks.com/topic/230169-generate-random-numbers/#findComment-1185358 Share on other sites More sharing options...
oldmatt Posted March 10, 2011 Share Posted March 10, 2011 Or you could use mt_rand(). http://www.php.net/manual/en/function.mt-rand.php Quote Link to comment https://forums.phpfreaks.com/topic/230169-generate-random-numbers/#findComment-1185361 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.