Bricktop Posted October 10, 2009 Share Posted October 10, 2009 Hi all, Not sure if this is possible without using CRON (which I don't want to do) but just thought I would get your opinion. I have a script which displays a random line from a text file every time the page is loaded, it's quite simple code which reads in the text file, explodes the contents and then uses the rand() function to display a random quote. Is there any way I can change the above so it only outputs a quote once per day? Either using an if statement based on the date/time or another PHP-only method? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/177172-solved-quote-of-the-day/ Share on other sites More sharing options...
Daniel0 Posted October 10, 2009 Share Posted October 10, 2009 I would just store it in a file and check the file's last modification date. If it hasn't been modified within the last 24 hours, show the quote in there, otherwise update it. You can use filemtime to check the modification date. Quote Link to comment https://forums.phpfreaks.com/topic/177172-solved-quote-of-the-day/#findComment-934163 Share on other sites More sharing options...
Bricktop Posted October 10, 2009 Author Share Posted October 10, 2009 Thanks Daniel Quote Link to comment https://forums.phpfreaks.com/topic/177172-solved-quote-of-the-day/#findComment-934177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.