| View previous topic :: View next topic |
| Author |
Message |
rickb
Joined: 25 Apr 2009 Posts: 9
|
Posted: Sat Apr 25, 2009 8:29 pm Post subject: Random Number generation in PHP |
|
|
| I would like to know how to generate random number in PHP. |
|
| Back to top |
|
 |
|
|
 |
rickb
Joined: 25 Apr 2009 Posts: 9
|
Posted: Sat Apr 25, 2009 8:32 pm Post subject: |
|
|
I figured out that the answer was easy. For example
generates the random number between 0 and 9.
Also
generates random number between 1 and 6. |
|
| Back to top |
|
 |
Anubhav
Joined: 28 Apr 2009 Posts: 2
|
Posted: Tue Apr 28, 2009 11:43 am Post subject: Reply |
|
|
Hi, This is Anubhav
You can use "rnd" to generate random numbers. |
|
| Back to top |
|
 |
William James
Joined: 12 May 2009 Posts: 2
|
Posted: Tue May 12, 2009 11:36 am Post subject: Re: |
|
|
Hi,
By using "mt_rand" function u can generate random numbers easily.
Regards |
|
| Back to top |
|
 |
madhu2300
Joined: 30 May 2009 Posts: 25
|
Posted: Sun May 31, 2009 5:11 pm Post subject: |
|
|
This is the solution --
Definition: The rand () function is used to generate a random number in PHP. It can also be used to generate a random number within a specific range (for example a number between 10 and 30.) On a some platforms, Windows for example, if unspecified the largest number that will be generated is 32768, however you can set a specific range to include higher numbers.
Examples:
<php> |
|
| Back to top |
|
 |
havard
Joined: 04 Jun 2009 Posts: 6
|
Posted: Thu Jun 04, 2009 4:11 am Post subject: |
|
|
Let's do some code that will generate a random number in PHP.The rand () function is used to generate a random number in PHP. It can also be used to generate a random number within a specific range (for example a number between 10 and 30.)
On a some platforms, Windows for example, if unspecified the largest number that will be generated is 32768, however you can set a specific range to include higher numbers.
Examples:
<?
<php>
?> _________________ http://ezdia.org |
|
| Back to top |
|
 |
Fnand
Joined: 28 Jun 2009 Posts: 36
|
Posted: Fri Jul 03, 2009 12:08 pm Post subject: |
|
|
hey here is how you can create a random number in php. as havard has said correctly we have to use the rand() function in order togenerate a random number.We can generate the random number in php by giving the code as below-
Rand () function to generate random number.
Rand () %9, generates random number from 0-9 |
|
| Back to top |
|
 |
jitendra45
Joined: 04 Jul 2009 Posts: 26
|
Posted: Sat Jul 04, 2009 10:12 am Post subject: generate random number |
|
|
| It can be done with the help of rand() in the code that we write. Also this rand() is existing in all the languages which is best to create random numbers. |
|
| Back to top |
|
 |
|