如何在php中禁用每月30天的公共假日列表数组?

如何在php中禁用每月30天的公共假日列表数组?,php,loops,date,while-loop,Php,Loops,Date,While Loop,假设公共假日日期列表为- $public_holiday = array('2018-08-09','2018-08-14','2018-08-26'); 从当前日期开始,我有一个30天的循环- $date = '2018-08-09'; $end_date = '2018-09-08'; while (strtotime($date) <= strtotime($end_date)) { $date = date ("Y-m-d", strtotime("+1 day",

假设公共假日日期列表为-

$public_holiday = array('2018-08-09','2018-08-14','2018-08-26');
从当前日期开始,我有一个30天的循环-

$date = '2018-08-09';
$end_date = '2018-09-08';

while (strtotime($date) <= strtotime($end_date)) {

    $date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
    $nameOfDay = date('l', strtotime($date));
    echo 'Date-'.$date.'-'.'Day-'.$nameofDay.'<br/>';
}
$date='2018-08-09';
$end_日期='2018-09-08';

while(strotime($date)
!在数组($date,$public\u holiday)中
?不起作用,实际上日期不匹配。我不知道为什么。循环时我无法匹配公共假日日期。它不起作用,因为日期周围没有引号!所以$date=2018-8-9=2001,不是'2018-08-09'不起作用,兄弟,实际上$date和$end_日期来自数据库,这里我提到这些日期用于测试。我是不要只问数组中的函数来解决这个问题或其他函数。哦,sry,在数组中的第三个公共假日中犯了与您相同的错误。现在应该可以工作了。
<?php
$date = '2018-08-09';
$end_date = '2018-09-08';

$public_holiday = array('2018-08-09','2018-08-14','2018-08-26');
while (strtotime($date) <= strtotime($end_date)) {
    $date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
    if(!in_array($date, $public_holiday)) {
        $nameOfDay = date('l', strtotime($date));
        echo 'Date-'.$date.'-'.'Day-'.$nameOfDay.'<br/>';
    }
}