- print_r: documentation ( source)
- strtolower: documentation ( source)
<?php
$begin = new DateTime('2020-12-01');
$end = new DateTime('2021-01-01');
$row = array('monday' => 1, 'tuesday' => 0, 'wednesday' => 1, 'thursday' => 1, 'friday' => 1, 'saturday' => 0, 'sunday' => 1);
$interval = new DateInterval('P1D');
$daterange = new DatePeriod($begin, $interval ,$end);
$array = array();
foreach($daterange as $date){
if ($row[strtolower($date->format('l'))]) {
$array[] = $date->format("D Y-m-d");
}
}
print_r($array);