...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

How To Create A Random Number In PHP

Computing : Learning PHP

Creating a simple random number in PHP is simple and you just call the rand function like this:

rand(minimum, max)

thus to get a number between 1 and 100 inclusive call:

$randnumber = rand(1,100);

Note that oftentimes you will want something more random than this and therefore you may wish to seed the function.

There are also other functions that can be combined to get a bigger or more likely random number, for instance you can use the time to get a random number.


By: Stephen

Share on Facebook: On Twitter: TwitterTweet this!

  Reply to How To Create A Random Number In PHP

  Receive Our Newsletter




Questions about learn PHP:

Ask question

More Articles:
How to Synchronize Your Computer Clock with an Internet Time Server
How to turn off Auto Complete
How to find affected rows in mySQL