3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $year = 2012; $months = array(01,02,03,04,05,06,07,08,09,10,11,12); $days = array(01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30); foreach($months AS $month) foreach($days AS $day) if((int)$year && (int)$month && (int)$day && rand(0,100)>15) $datesWS[] = new DateTime(implode('-',array($year,$month,$day))); usort($datesWS, function ($a, $b){ return $a == $b ? 0 : $a > $b ? 1 : -1; }); $dateIni = count($datesWS)>0 ? reset($datesWS) : 0; $dateIni = $dateIni->modify( '-1 day' ); $dateEnd = count($datesWS)>0 ? end($datesWS) : 0; $dateEnd = $dateEnd->modify( '+1 day' ); $interval = new DateInterval('P1D'); $datesRange = iterator_to_array(new DatePeriod($dateIni, $interval, $dateEnd)); // Get excluded dates $excludeDates = array_udiff($datesRange, $datesWS, function ($a, $b) { return $a == $b ? 0 : 1; }); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesWS))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesRange))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$excludeDates))); ?>

Abusive script

This script was stopped while abusing our resources