...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.


Profile image!
By: Stephen

  More about learn PHP

  Reply to How To Create A Random Number In PHP

  Receive Our Newsletter

  Send to friend

learn PHP picture



Questions about learn PHP:

Ask question

More Articles:
How to stop applications taking over on XP
How to make your website more accessible
How to Reduce 10 Second Scandisk Wait Time