显示日期的无尽循环

时间:2015-10-13 18:14:07

标签: php while-loop strtotime

突然间,代码中没有任何变化,以下部分在无限循环中运行(两年多来它运作良好):

$date = date("d.m.Y l", strtotime($supplyDate));
$end = date("d.m.Y l",strtotime("+1 months"));

if(!empty($date_dif)) {
$i = 1;
// PATCH one day minus
$date = date("d.m.Y l", strtotime($date)-(86400));
while (strtotime($date)<strtotime($end)) {
    $date = date("d.m.Y l", strtotime($date)+(86400));
    $day = date("l", strtotime($date));
    if($day == "Saturday" && (intval($isSaturdayOpen) == 0 && intval($date_dif) == 1)){ continue;}
    if($day == "Sunday" && (intval($isSundayOpen) == 0 && intval($date_dif) == 1)){ continue;}

    $tab_content .= '<option value="'.strtotime($date).'">'.utf8_encode(strftime('%d.%m.%Y %A',strtotime($date))).'</option>';

    $i++;
    if($i==10){
        break;
    }   
}
}

1 个答案:

答案 0 :(得分:0)

很奇怪,但你可以在代码的末尾使用一个技巧:

if((int)$i===10){
     break;    /* You could also write 'break 1;' here. */
}

如果类型无法识别$i,您可以像整数一样进行转换并与整数进行比较。

我在这里找不到其他问题。

相关问题