3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = strtotime("01-jan-2018"); $next = strtotime("next day", $start); $festivi = array( "Capodanno" => getMyDate("01-jan-2018"), "Epifania" => getMyDate("06-jan-2018"), "Pasqua" => getMyDate("01-apr-2018"), "Pasquetta" => getMyDate("02-apr-2018"), "Liberazione" => getMyDate("25-apr-2018"), "Lavoratori" => getMyDate("01-mag-2018"), "Repubblica" => getMyDate("02-jun-2018"), "Patrono" => getMyDate("29-jun-2018"), "Ferragosto" => getMyDate("15-aug-2018"), "TuttiSanti" => getMyDate("01-nov-2018"), "Immacolata" => getMyDate("08-dic-2018"), "Natale" => getMyDate("25-dic-2018"), "SantoStefano" => getMyDate("26-dic-2018") ); while($start != strtotime("01 jan 2019")){ if(isFestivo($festivi, $start)) echo date('d/m/Y', $start)."t".$festivo[getFestivoIndex($festivi, $start)]["descrizione"]."\n"; else if(date('w',$start)==6) echo date('d/m/Y', $start)."tS\n"; else if(date('w',$start)==7) echo date('d/m/Y', $start)."tD\n"; else $start = strtotime("next day", $start); $start = strtotime("next day", $start); } function getMyDate($myDate){ return date('d/m/Y', strtotime($myDate)); } function isFestivo($festivi, $myDate){ foreach($festivi as $tempDescription => $tempDate) if($myDate == $tempDate) return true; return false; } function getFestivoIndex($festivi,$myDate){ $count = 0; foreach($festivi as $tempDescription => $tempDate) if($myDate == $tempDate) return $count; else $count++; return -1; }
based on KZfCH
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0beta1
13/01/2018tS 20/01/2018tS 27/01/2018tS 03/02/2018tS 10/02/2018tS 17/02/2018tS 24/02/2018tS 03/03/2018tS 10/03/2018tS 17/03/2018tS 24/03/2018tS 31/03/2018tS 07/04/2018tS 14/04/2018tS 21/04/2018tS 28/04/2018tS 05/05/2018tS 12/05/2018tS 19/05/2018tS 26/05/2018tS 02/06/2018tS 09/06/2018tS 16/06/2018tS 23/06/2018tS 30/06/2018tS 07/07/2018tS 14/07/2018tS 21/07/2018tS 28/07/2018tS 04/08/2018tS 11/08/2018tS 18/08/2018tS 25/08/2018tS 01/09/2018tS 08/09/2018tS 15/09/2018tS 22/09/2018tS 29/09/2018tS 06/10/2018tS 13/10/2018tS 20/10/2018tS 27/10/2018tS 03/11/2018tS 10/11/2018tS 17/11/2018tS 24/11/2018tS 01/12/2018tS 08/12/2018tS 15/12/2018tS 22/12/2018tS 29/12/2018tS