I'm making a function so that I can make recurring events.
The first thing I need to do is duplicate the event date at set intervals. For example (August 2, 2019) with 1 week interval will produce; August 9, 2019 August 16, 2019 August 23, 2019 and so on. I want to be able to set the number of intervals. Like 4 weeks, 5... 100 weeks into the future.
Here is my attempt: 1. I don't know how to take the $newdate and then input that into the $event_date slot with each loop. 2. I don't know how to output the set of new dates in an array.
<?php
function recurring_event($event_date, $num_days=''){
for($i=0 ; $i < 8 ; $i++ ){
$date = date_create($event_date);
$newdate = date_add($date, date_interval_create_from_date_string($num_days));
echo date_format($newdate, 'D, F jS, Y');
}
}
recurring_event($event_date, '7days');
?>
I'm too novice to actually conceptualize how I can tackle this problem. I've tried searching this site, the PHP manual.. Tried for() loops, continue logic, etc.
Any help with this problem would be greatly appreciated.