If statement hangs script
Posted on 2007-10-12
I'm using the following code to select dates by comparing the week day to a selected checkbox. The values of the checkboxes are stored in an array and the values are 0 for Sunday, 1 for Monday, etc. So if Monday, Wednesday and Friday are selected, the dates that fall into those days from a date range will get printed out. However, when I add the if statement to compare the date with the week number, the script hangs on and doesn't finish. If I take out the if statement, all the days that fall between the range are printed out. Do I have an error?
$compare_date = $press_date;
foreach($myarray as $value)
while ($press_date <= $recurrence_stop)
if(date('w',strtotime($press_date)) == $value)
echo $press_date;echo '-';echo date('w',strtotime($press_date));echo '-'; echo $value;echo '<br />';
$press_date = date('Y-m-d',strtotime("+1 day, $press_date"));
} //Closes while
$press_date = $compare_date;
The posted values are $press_date and $recurrence_stop. I store the original $press_date into another variable so it can be reassigned to the variable $press_date. Thanks!