Javatpoint Logo
Javatpoint Logo

Rand() function

The rand() function is used to generate random integer.

Syntax:

Parameter Description Required/Optional
min Specifies the lowest number to returned. Optional
max Specifies the highest number to be returned. Optional

Example1

Output:

Get Random number by using rand() function: 81627923
Get Random number by using rand() function: 1857469033
Note: Refresh page to get another randome value

Example2

Output:

To get random number b/w (rand(10,100)): 15
Note: Refresh page to get new random number

Note: The mt_rand() math function is used to get a bet ter random value, and is 4 times faster than rand() function.

Example3

Output:

Array ( [0] => 7 [1] => 6 [2] => 9 [3] => 15 [4] => 10 [5] => 12 [6] => 10 [7] => 14 [8] => 9 [9] => 12 [10] => 13 )

Next TopicPHP Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA