PHP 8.5.0 Alpha 2 available for testing

Voting

: max(eight, one)?
(Example: nine)

The Note You're Voting On

edublancoa at gmail dot com
20 years ago
Another use of srand is to obtain the same value of rand in a determined time interval. Example: you have an array of 100 elements and you need to obtain a random item every day but not to change in the 24h period (just imagine "Today's Photo" or similar).
<?php
$seed
= floor(time()/86400);
srand($seed);
$item = $examplearray[rand(0,99)];
?>
You obtain the same value every time you load the page all the 24h period.

<< Back to user notes page

To Top