PHP Generate List of Random Float Numbers Example
Hi Developer,
In this tutorial, we will see how to get the random float 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 float number.
The rand() function is used to generate a random float number. To generate a random float in some range.
In this example, we will use the rand() function. Create a function to generate a random float number. It will generate different float numbers between the 1 and 10 range.
Example:
<?php
//Get random float numbers
$randomFloat = rand(1, 10) / 10;
//print random float numbers
print_r($randomFloat);
?>
Output:
0.6
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 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