3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$current_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")); //$permit_active_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $current_date = mktime(0, 0, 0, 10, 25, 2018); $permit_active_date = mktime(0, 0, 0, 10, 25, 2018); $pay_frequency = "BW"; $UCDHS_MasterPaySchedule = array ( "BW" => array ( array ( "file_submit_date" => mktime(0,0,0,9,14,2018), "pay_check_date" => mktime(0,0,0,9,19,2018), "park_period_start" => mktime(0,0,0,10,1,2018), "park_period_end" => mktime(0,0,0,10,15,2018), "check_num" => 1 ), array ( "file_submit_date" => mktime(0,0,0,9,28,2018), "pay_check_date" => mktime(0,0,0,10,3,2018), "park_period_start" => mktime(0,0,0,10,16,2018), "park_period_end" => mktime(0,0,0,10,31,2018), "check_num" => 2 ), array ( "file_submit_date" => mktime(0,0,0,10,12,2018), "pay_check_date" => mktime(0,0,0,10,17,2018), "park_period_start" => mktime(0,0,0,11,1,2018), "park_period_end" => mktime(0,0,0,11,15,2018), "check_num" => 3 ), array ( "file_submit_date" => mktime(0,0,0,11,8,2018), "pay_check_date" => mktime(0,0,0,11,14,2018), "park_period_start" => mktime(0,0,0,11,16,2018), "park_period_end" => mktime(0,0,0,11,30,2018), "check_num" => 4 ), array ( "file_submit_date" => mktime(0,0,0,11,21,2018), "pay_check_date" => mktime(0,0,0,11,28,2018), "park_period_start" => mktime(0,0,0,12,1,2018), "park_period_end" => mktime(0,0,0,12,15,2018), "check_num" => 5 ), array ( "file_submit_date" => mktime(0,0,0,12,7,2018), "pay_check_date" => mktime(0,0,0,12,12,2018), "park_period_start" => mktime(0,0,0,12,16,2018), "park_period_end" => mktime(0,0,0,12,31,2018), "check_num" => 6 ) ) ); //reduce array to pay schedule // $arrPaySchedule = $UCDHS_MasterPaySchedule[$pay_frequency]; //find pay cycle where parking period includes permit start date $pay_cycle_for_active_date = get_pay_cycle_for_active_date($current_date, $permit_active_date, $UCDHS_MasterPaySchedule[$pay_frequency]); print $pay_cycle_for_active_date; /** * Number of days between two dates. * * @param date $dt1 First date * @param date $dt2 Second date * @return int */ function daysBetween($dt1, $dt2) { // return date_diff( // date_create($dt2), // date_create($dt1) // )->format('%a'); return date_diff( $dt2, mktime(0, 0, 0, 10, 25, 2018) )->format('%a'); } function get_pay_cycle_for_active_date($current_date, $permit_active_date, $arr_pay_schedule) { // note: function assumes that pay period data is ordered earliest to latest, in the arrPaySchedule array //default values: $current_period_id = -1; $active_period_id = -1; //$return_file_submit_date //pay_check_date //park_period_start //park_period_end //check_num //loop through pay periods... foreach($arr_pay_schedule as $period_num => $period) { //find current parking period if ($current_date >= $period["park_period_start"] && $current_date <= $period["park_period_end"]) { $current_period_id = $period_num; } //find parking period which contains permit_active_date if ($permit_active_date >= $period["park_period_start"] && $permit_active_date <= $period["park_period_end"]) { $active_period_id = $period_num; } //determine number of days permit is valid in perid permit becomes valid $days_valid_in_active_period = daysBetween($permit_active_date, $period["park_period_end"]); } echo "current_period_id = ".$current_period_id."\f\r"; echo "active_period_id = ".$active_period_id."\f\r"; echo "days_valid_in_active_period = ".$days_valid_in_active_period."\f\r"; echo "permit_active_date = ".$permit_active_date."\f\r"; echo "period['park_period_end'] = ".$period["park_period_end"]."\f\r"; return ""; // $arrSelectedSchedule = array_filter($arrPaySchedule, function($e) use($permit_active_date) {return ($e["park_period_start"]<=$permit_active_date && $e["park_period_end"]>=$permit_active_date);}); // print_r($arrSelectedSchedule); // return array_search() // return count(array_filter($arrPaySchedule, function($e) use($permit_active_date) {return ($e["park_period_start"]<=$permit_active_date && $e["park_period_end"]>=$permit_active_date);})); } //$min=mktime(0,0,0,10,1,2018); //$max=mktime(0,0,0,10,4,2018); //print count(array_filter($UCDHSPaySchedule["BW"], function($e) use($min,$max) {return ($e["permit_active_date"]>$min && $e["permit_active_date"]<$max);})); //function gets the number of submittion dates between the $current_date and the submission date for permit starting on $active_date //function get_cycle_count($current_date, $active_date, $UCDHSPaySchedule) { //print count(array_filter($UCDHSPaySchedule["BW"], function($e) use($min,$max) {return ($e["permit_active_date"]>$min && //$e["permit_active_date"]<$max);})); //} //$cars = array ( //"Volvo" => array("Volvo",22,18), //"BMW" => array("BMW",15,13), //"Saab" => array("Saab",5,2), //"Land Rover" => array("Land Rover",17,15) //); //print $cars['Volvo'][0]; ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0130.00318.55
8.3.50.0090.00618.16
8.3.40.0070.00719.09
8.3.30.0040.01119.09
8.3.20.0030.00619.46
8.3.10.0040.00423.52
8.3.00.0030.00520.95
8.2.180.0070.01118.42
8.2.170.0110.01122.96
8.2.160.0130.00720.40
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0000.00818.28
8.2.120.0000.00826.35
8.2.110.0060.00319.53
8.2.100.0090.00317.86
8.2.90.0000.00817.87
8.2.80.0060.00317.97
8.2.70.0060.00318.18
8.2.60.0000.00918.41
8.2.50.0030.00518.10
8.2.40.0000.00919.58
8.2.30.0050.00319.41
8.2.20.0000.00718.31
8.2.10.0000.00718.20
8.2.00.0060.00317.96
8.1.270.0080.00020.78
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00622.38
8.1.230.0060.00622.30
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0070.00317.73
8.1.190.0040.00417.47
8.1.180.0000.00818.10
8.1.170.0000.00918.71
8.1.160.0040.00418.97
8.1.150.0060.00319.05
8.1.140.0040.00422.26
8.1.130.0000.01020.38
8.1.120.0040.00417.63
8.1.110.0030.00517.68
8.1.100.0000.00717.70
8.1.90.0000.00817.73
8.1.80.0000.00717.66
8.1.70.0070.00417.72
8.1.60.0000.01017.74
8.1.50.0070.00317.58
8.1.40.0000.01217.63
8.1.30.0000.00817.72
8.1.20.0000.00717.76
8.1.10.0050.00317.79
8.1.00.0040.00417.79
8.0.300.0080.00018.77
8.0.290.0030.00516.84
8.0.280.0030.00318.64
8.0.270.0030.00317.41
8.0.260.0000.00718.55
8.0.250.0070.00417.29
8.0.240.0000.00717.10
8.0.230.0000.00717.13
8.0.220.0100.00017.08
8.0.210.0040.00417.08
8.0.200.0030.00317.25
8.0.190.0000.00717.17
8.0.180.0060.00317.07
8.0.170.0090.00017.22
8.0.160.0080.00017.20
8.0.150.0050.00217.08
8.0.140.0080.00017.05
8.0.130.0030.00313.58
8.0.120.0040.00417.19
8.0.110.0040.00417.11
8.0.100.0070.00017.08
8.0.90.0000.00817.13
8.0.80.0100.00717.19
8.0.70.0040.00417.03
8.0.60.0050.00317.18
8.0.50.0020.00517.02
8.0.30.0100.00717.30
8.0.20.0100.01517.40
8.0.10.0050.00217.29
8.0.00.0130.00517.11
7.4.330.0050.00015.55
7.4.320.0070.00016.77
7.4.300.0040.00416.78
7.4.290.0070.00016.77
7.4.280.0030.00616.80
7.4.270.0030.00616.54
7.4.260.0040.00416.57
7.4.250.0000.00716.79
7.4.240.0070.00016.54
7.4.230.0000.00716.77
7.4.220.0040.00416.78
7.4.210.0060.00816.86
7.4.200.0040.00416.68
7.4.160.0090.01016.77
7.4.140.0110.01017.86
7.4.130.0120.00616.92
7.4.120.0110.00916.87
7.4.110.0130.00616.84
7.4.100.0070.01116.56
7.4.90.0070.01016.74
7.4.80.0090.01519.39
7.4.70.0070.01616.77
7.4.60.0100.00616.71
7.4.50.0120.00016.54
7.4.40.0100.00716.96
7.4.00.0090.00315.13
7.3.330.0030.00313.58
7.3.320.0050.00013.66
7.3.310.0040.00216.45
7.3.300.0000.00716.48
7.3.290.0030.00616.64
7.3.280.0050.01016.63
7.3.260.0100.00916.72
7.3.240.0090.00916.72
7.3.230.0050.01316.72
7.3.210.0110.00716.55
7.3.200.0100.00716.85
7.3.190.0150.00316.66
7.3.180.0030.01316.67
7.3.170.0140.00916.78
7.3.160.0100.01416.64
7.2.330.0110.00916.87
7.2.320.0090.00916.93
7.2.310.0060.01116.99
7.2.300.0110.00516.91
7.2.290.0170.00416.78
7.2.110.0620.01315.21
7.2.100.0310.00615.14
7.2.90.0670.00914.98
7.2.80.0970.01014.65
7.2.70.0720.01215.34
7.2.60.0770.00315.48
7.2.50.0910.00415.16
7.2.40.0820.01015.21
7.2.30.0730.00615.48
7.2.20.0800.00915.46
7.2.10.0530.01315.52
7.2.00.0540.00615.30
7.1.230.0730.00414.18
7.1.220.0720.00014.29
7.1.210.0460.01214.02
7.1.200.0830.00713.66
7.1.190.0190.00614.06
7.1.180.0640.00714.11
7.1.170.0790.00714.16
7.1.160.0690.00314.10
7.1.150.0550.01514.11
7.1.140.0610.00314.07
7.1.130.0860.00314.07
7.1.120.0720.00914.19
7.1.110.0800.00314.22
7.1.100.0580.00714.32
7.1.90.0310.00913.89
7.1.80.0640.00614.02
7.1.70.0840.00014.22
7.1.60.0720.01031.86
7.1.50.0930.01032.31
7.1.40.0780.02231.69
7.1.30.1080.01531.99
7.1.20.1200.01032.06
7.1.10.0750.00014.05
7.1.00.0170.00814.02
5.6.380.0040.01314.37

preferences:
52.26 ms | 404 KiB | 6 Q