3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $activities= array("Date,Num_Days,Event,Location","3/3/2018,1,Rosary of the Unborn,In Front of Planned Parenthood","4/4/2018,2,Sell Raffle Tickets,St. Eugene Church"); $monthNames = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $omonth = -1; $start = TRUE; print_r ($activities); print_r ($monthNames); print_r ($omonth); if ($start == True) {; print_r ("TRUE"); } $today = new DateTime("yesterday"); print_r ($today); $len_activities=sizeof($activities); for ($i = 1; $i < $len_activities; $i++) { $activity = $activities[$i]; print_r ($activity . "\n"); $activity = $activities[$i]; $activity_array = str_getcsv ($activity,",") ; print_r ($activity_array); $d = new DateTime($activity_array[0]); print_r ($d); $month = $d->format("n"); print_r ("\n".$month."\n"); }
based on G6RqD
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
Array ( [0] => Date,Num_Days,Event,Location [1] => 3/3/2018,1,Rosary of the Unborn,In Front of Planned Parenthood [2] => 4/4/2018,2,Sell Raffle Tickets,St. Eugene Church ) Array ( [0] => January [1] => February [2] => March [3] => April [4] => May [5] => June [6] => July [7] => August [8] => September [9] => October [10] => November [11] => December ) -1TRUEDateTime Object ( [date] => 2018-03-26 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) 3/3/2018,1,Rosary of the Unborn,In Front of Planned Parenthood Array ( [0] => 3/3/2018 [1] => 1 [2] => Rosary of the Unborn [3] => In Front of Planned Parenthood ) DateTime Object ( [date] => 2018-03-03 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) 3 4/4/2018,2,Sell Raffle Tickets,St. Eugene Church Array ( [0] => 4/4/2018 [1] => 2 [2] => Sell Raffle Tickets [3] => St. Eugene Church ) DateTime Object ( [date] => 2018-04-04 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) 4