Anyone have any ideas on how to make a function reset every 24-hours? For example, I
have a function that grabs a random quote from a file and selects a new one every time
the page is reloaded. What I want, however, is for the quote to remain the same for a
day and then reset at some specified time (say midnight) and grab a new random quote
for the next day. It seems like their should be any easy way to do this using mktime(
) or a similar function but I'm not fully grasping it. Any ideas on how to do this
would be much appreciated.
Rudy
function displayRandomQuote() {
$file_input_name = "quotes.data";
srand ((double) microtime() * 10000000);
$open_file = file($file_input_name);
$random_index = array_rand($open_file);
$unformatted = $open_file[$random_index];
$quoteOfTheDay = explode("::",$unformatted);
$quote = $quoteOfTheDay[0];
$author = $quoteOfTheDay[1];
echo "<i>";
echo $quote."<br></i>." -- ".$author;
}