oz11 Posted July 29, 2022 Share Posted July 29, 2022 Hey, simple question here. How do i generate a random number daily between 1 and 10? It needs to say the same throughout the day and change he next, etc. Can't figure it out myself. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/315104-daily-random-number-from-1-to-10/ Share on other sites More sharing options...
gw1500se Posted July 29, 2022 Share Posted July 29, 2022 PHP has a 'rand' function. Quote Link to comment https://forums.phpfreaks.com/topic/315104-daily-random-number-from-1-to-10/#findComment-1598738 Share on other sites More sharing options...
requinix Posted July 29, 2022 Share Posted July 29, 2022 To get a new number every day, seed the RNG with a number that stays the same all day long - say, the date in YYYYMMDD format - then request a random number. With the same seed you'll get the same sequence of numbers. Quote Link to comment https://forums.phpfreaks.com/topic/315104-daily-random-number-from-1-to-10/#findComment-1598771 Share on other sites More sharing options...
ginerjm Posted July 29, 2022 Share Posted July 29, 2022 You could setup a cron job that runs at midnight and generates the number and store it in a db table for every script to access when it begins. Quote Link to comment https://forums.phpfreaks.com/topic/315104-daily-random-number-from-1-to-10/#findComment-1598776 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.