I’m learning PHP and wondering is it possible to use the for statement to run an automated function. I understand how variables and arrays work, but I just can’t figure this one out.
Say I have a basketball schedule and I want to show the date of the next game, after the date of the most recent game; so if there’s a game on the 3rd, on the 4th I would want the next game slot to show that the next game is on the 5th, the next game date. I could create the games in the array but I don’t seem to get how to call the right game on the right day.
Some direction would be helpful.
This can be easily done using timestamp, timestamp is a long number of seconds from Jan 1970, so if you can convert your date to timestamp you can easily compare it with other date timestamps. PHP has a function strtotime() which is use to convert any string date to its appropriate timestamp number, here is a example