PHP - Number: Generating Random NumbersTag: number, random Category: PHP Basicpost: 16 Mar 2008 read: 48 PHP Number Tips - Part 18: If you want generate one or more random numbers, you can use PHP's rand( ) function:
Generating a random number in PHP is as simple as calling the rand( ) function. The getrandmax( ) function is a good choice in here where it returns the maximum value that rand( ) could possibly generate on your system. Here's an illustration:
If you need more than one random number, use rand( ) in combination with a loop and array such as:
|
| | Give Your Opinion | Recommend |
|

