...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 create a printable website
How to reduce the size of the recycle bin
How to read your site aloud