I just did some testing on my initial code above and it doesn't work. It's skipping to the next week once a date is found.
I'm redoing it based on an open source program I'm dissecting from.
$valid = true;
for($x=0;$x < $frequency*7;$x++){
$occurance = date('Y-m-d H:i:s', mktime(date('H', strtotime($startDate)), date('i', strtotime($startDate)), 0, date('m', strtotime($startDate)) , date('d', strtotime($startDate))+(($x*7)*$interval), date('y', strtotime($startDate)) ) );
$lastweek=sprintf("%02d", (strftime('%W',strtotime($occurance))-0));
$year = strftime('%Y',strtotime($occurance));
for ($i=0;$i<=6;$i++){
$thisDOW = strftime('%w',strtotime("+{$i} day",strtotime($occurance)));
$occDate = strftime('%Y-%m-%d', strtotime("+{$i} day",strtotime($occurance)));
//-- Check if the date is one of the assigned and less than the end date
if(in_array($thisDOW, $onwd) && strtotime($occDate) <= strtotime($endDate)){
$ar_Recur[] = $occDate;
}
//-- If the date is past the end date end the loop
if(strtotime($occDate) >= strtotime($endDate)){
$valid = false; //-- End the loop
break;
}
}
if(!$valid) break;
}
echo implode('<br/>', $ar_Recur);