PHP Generate List of Random Numbers Between 0 and 100 Example

03-Apr-2023

.

Admin

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

I hope it can help you...

#PHP