3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
23.9 ms | 405 KiB | 5 Q