Rand() functionThe rand() function is used to generate random integer. Syntax:
Example1Output: Get Random number by using rand() function: 81627923 Get Random number by using rand() function: 1857469033 Note: Refresh page to get another randome value Example2Output: 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.Example3Output: 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
|