PHP Generate List of Random Numbers Between 0 and 100 Example
Hi Developer,
In this tutorial, we will see how to get the random number using the rand() function in PHP, along with knowing its implementation through the example. The rand() is an inbuilt function in PHP used to generate a random number.
The rand() function is used to generate a random integer. To generate a random integer in some range:
In this example, we will use the rand() function. The rand(0,100) will return a random integer in the range [0,100].
Example:
<?php
//Get random number 0 to 100
$randomNumber = rand(0,100);
print_r($randomNumber);
?>
Output:
87
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example
- How To Add Year To Current Date In Php?