0
Random numbers
Can someone explain this code to me? It's in one of the quizzes that it outputs 2,8,24... but NOT 6 <?php $random = rand(1,3); $result = 24/$random; echo $result; ?>
3 odpowiedzi
+ 1
It is because rand function in the example generates random numbers between 1 and 3 (including 3). So the maximum number in $random variable is 3 => 24/3 = 8. It's not 6 because the upper limit in rand function is 3 not 4. You can find more info about rand function here:https://www.php.net/manual/en/function.rand.php. Hope it helps you 😉
0
Thanks a lot @TheWhiteCat
0
You are welcome Jesse Brite 😉