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 r242t
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0rc3
13/01/2018 S 20/01/2018 S 27/01/2018 S 03/02/2018 S 10/02/2018 S 17/02/2018 S 24/02/2018 S 03/03/2018 S 10/03/2018 S 17/03/2018 S 24/03/2018 S 31/03/2018 S 07/04/2018 S 14/04/2018 S 21/04/2018 S 28/04/2018 S 05/05/2018 S 12/05/2018 S 19/05/2018 S 26/05/2018 S 02/06/2018 S 09/06/2018 S 16/06/2018 S 23/06/2018 S 30/06/2018 S 07/07/2018 S 14/07/2018 S 21/07/2018 S 28/07/2018 S 04/08/2018 S 11/08/2018 S 18/08/2018 S 25/08/2018 S 01/09/2018 S 08/09/2018 S 15/09/2018 S 22/09/2018 S 29/09/2018 S 06/10/2018 S 13/10/2018 S 20/10/2018 S 27/10/2018 S 03/11/2018 S 10/11/2018 S 17/11/2018 S 24/11/2018 S 01/12/2018 S 08/12/2018 S 15/12/2018 S 22/12/2018 S 29/12/2018 S