I am new to laravel . I want to know what does rand(1,6) means ?
if (rand(1,6) < 5)
{ //some code
}
Could someone please brief it in detail .
I am new to laravel . I want to know what does rand(1,6) means ?
if (rand(1,6) < 5)
{ //some code
}
Could someone please brief it in detail .
This is a basic php function - https://www.php.net/manual/en/function.rand.php
It gets a pseudo-random integer from 1 to 6, and if the random number is less than 5 the code is run.
It's a php function to generate random numbers between the two given parameters
Here the chance will be 2/3 that the if statement gets executed
https://www.php.net/manual/de/function.rand.php
EDIT:
The chance is 2/3 because the function will generate a random number between 1 and 6 -> 1, 2, 3, 4, 5 or 6 which means that there are 4 numbers smaller than 5. Thus our chance is 4 numbers of 6 numbers (=> 4/6) which is equal to 2/3