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, $dt1 )->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.0070.01018.55
8.3.50.0120.00418.08
8.3.40.0040.01119.09
8.3.30.0120.00419.06
8.3.20.0040.00419.46
8.3.10.0070.00023.55
8.3.00.0030.00520.77
8.2.180.0040.01418.66
8.2.170.0070.01022.96
8.2.160.0070.00720.46
8.2.150.0070.00024.18
8.2.140.0140.00024.66
8.2.130.0130.00618.28
8.2.120.0080.00026.35
8.2.110.0000.00919.34
8.2.100.0110.00018.16
8.2.90.0040.00417.75
8.2.80.0060.00318.00
8.2.70.0040.00418.18
8.2.60.0030.00518.28
8.2.50.0040.00418.10
8.2.40.0050.00319.59
8.2.30.0080.00019.51
8.2.20.0040.00418.20
8.2.10.0000.00918.30
8.2.00.0040.00418.02
8.1.280.0040.01125.92
8.1.270.0000.00820.86
8.1.260.0080.00026.35
8.1.250.0070.00728.09
8.1.240.0040.00422.30
8.1.230.0110.00422.20
8.1.220.0050.00318.01
8.1.210.0030.00518.77
8.1.200.0030.00617.47
8.1.190.0030.00617.59
8.1.180.0030.00618.10
8.1.170.0040.00418.84
8.1.160.0040.00419.09
8.1.150.0000.00819.16
8.1.140.0040.00422.30
8.1.130.0000.00720.25
8.1.120.0080.00017.72
8.1.110.0000.00817.61
8.1.100.0000.00717.64
8.1.90.0000.00717.63
8.1.80.0040.00417.74
8.1.70.0030.00717.72
8.1.60.0110.00017.76
8.1.50.0040.00417.75
8.1.40.0040.00817.71
8.1.30.0030.00617.75
8.1.20.0040.00417.88
8.1.10.0000.00917.62
8.1.00.0030.00517.76
8.0.300.0030.00618.77
8.0.290.0050.00217.00
8.0.280.0050.00318.69
8.0.270.0040.00417.34
8.0.260.0000.00818.73
8.0.250.0000.01117.27
8.0.240.0090.00017.29
8.0.230.0070.00017.14
8.0.220.0090.00017.14
8.0.210.0000.00717.17
8.0.200.0030.00317.16
8.0.190.0050.00217.30
8.0.180.0000.00717.18
8.0.170.0040.00417.14
8.0.160.0040.00417.11
8.0.150.0040.00417.20
8.0.140.0040.00417.17
8.0.130.0060.00013.55
8.0.120.0000.00717.05
8.0.110.0040.00417.13
8.0.100.0040.00417.05
8.0.90.0070.00017.06
8.0.80.0060.01017.20
8.0.70.0000.00817.25
8.0.60.0030.00517.22
8.0.50.0040.00417.10
8.0.30.0090.00817.33
8.0.20.0140.01317.50
8.0.10.0000.00817.40
8.0.00.0060.01216.94
7.4.330.0060.00015.55
7.4.320.0030.00316.68
7.4.300.0000.00616.53
7.4.290.0080.00016.66
7.4.280.0090.00016.76
7.4.270.0060.00316.66
7.4.260.0000.00716.68
7.4.250.0050.00316.76
7.4.240.0000.00816.77
7.4.230.0070.00016.60
7.4.220.0000.00816.80
7.4.210.0060.01116.81
7.4.200.0040.00416.88
7.4.160.0100.00916.80
7.4.140.0120.00817.86
7.4.130.0060.01216.74
7.4.120.0070.01316.75
7.4.110.0080.01116.79
7.4.100.0130.01016.81
7.4.90.0090.00916.70
7.4.80.0110.00719.39
7.4.70.0100.00616.62
7.4.60.0100.00616.80
7.4.50.0060.01016.63
7.4.40.0120.00416.96
7.4.10.0100.00315.09
7.4.00.0070.01115.28
7.3.330.0060.00013.52
7.3.320.0000.00513.55
7.3.310.0040.00416.55
7.3.300.0040.00416.61
7.3.290.0000.00716.64
7.3.280.0030.01216.58
7.3.260.0100.00916.71
7.3.240.0110.00716.74
7.3.230.0080.01116.70
7.3.210.0100.00616.65
7.3.200.0080.00816.76
7.3.190.0060.01316.83
7.3.180.0030.01316.76
7.3.170.0150.00916.87
7.3.160.0060.01316.65
7.3.130.0100.01015.00
7.3.120.0050.01114.97
7.3.110.0100.00714.98
7.3.100.0110.00115.07
7.3.90.0070.00815.10
7.3.80.0080.00314.96
7.3.70.0070.00914.87
7.3.60.0100.00515.13
7.3.50.0060.00514.79
7.3.40.0030.00914.71
7.3.30.0070.00414.97
7.3.20.0060.00416.69
7.3.10.0060.00616.79
7.3.00.0040.00916.83
7.2.330.0140.00817.11
7.2.320.0050.01417.05
7.2.310.0000.01717.06
7.2.300.0070.01016.81
7.2.290.0110.00816.59
7.2.260.0100.01014.97
7.2.250.0070.01215.17
7.2.240.0080.00815.25
7.2.230.0090.00315.07
7.2.220.0050.01015.18
7.2.210.0030.01215.31
7.2.200.0070.00715.24
7.2.190.0080.00715.37
7.2.180.0080.00615.15
7.2.170.0040.01115.22
7.2.160.0100.00315.44
7.2.150.0090.00917.01
7.2.140.0030.00617.15
7.2.130.0090.00517.06
7.2.120.0070.00717.01
7.2.110.0180.00616.54
7.2.100.0170.00616.54
7.2.90.0200.00516.56
7.2.80.0130.01016.59
7.2.70.0240.00716.63
7.2.60.0230.00716.71
7.2.50.0180.01216.75
7.2.40.0220.00916.69
7.2.30.0170.00916.60
7.2.20.0220.00816.64
7.2.10.0270.00616.61
7.2.00.0250.00816.65
7.1.330.0030.01115.86
7.1.320.0100.00615.79
7.1.310.0050.00815.95
7.1.300.0020.01415.94
7.1.290.0050.01015.80
7.1.280.0060.00815.89
7.1.270.0070.00716.03
7.1.260.0110.00215.79
7.1.250.0040.00815.82
7.1.240.0000.00916.04
7.1.230.0280.00714.97
7.1.220.0470.00514.88
7.1.210.0350.00715.01
7.1.200.0310.00714.96
7.1.190.0350.00614.84
7.1.180.0720.00914.79
7.1.170.0380.01014.93
7.1.160.0490.00614.87
7.1.150.0440.01014.84
7.1.140.0430.00714.94
7.1.130.0400.00914.97
7.1.120.0580.00514.93
7.1.110.0370.00815.03
7.1.100.0350.00614.99
7.1.90.0400.00715.14
7.1.80.0380.00515.06
7.1.70.0390.01014.99
7.1.60.0430.01423.95
7.1.50.0530.01023.79
7.1.40.0510.01023.91
7.1.30.0680.01323.80
7.1.20.0640.00523.95
7.1.10.0470.00515.03
7.1.00.0330.00915.06
7.0.330.0040.01115.63
7.0.320.0000.00915.63
7.0.310.0030.01015.47
7.0.300.0070.00715.58
7.0.290.0000.00815.44
7.0.280.0060.00615.53
7.0.270.0130.00315.61
7.0.260.0030.00915.25
7.0.250.0070.00715.45
7.0.240.0120.00315.41
7.0.230.0090.00915.27
7.0.220.0030.01315.57
7.0.210.0000.00815.45
7.0.200.0070.00715.57
7.0.190.0060.00315.44
7.0.180.0030.01015.33
7.0.170.0040.01215.55
7.0.160.0030.00715.44
7.0.150.0120.00015.38
7.0.140.0060.00615.45
7.0.130.0120.00615.57
7.0.120.0000.01415.65
7.0.110.0000.01315.57
7.0.100.0040.01115.57
7.0.90.0120.00615.21
7.0.80.0030.00715.20
7.0.70.0090.00615.40
7.0.60.0040.01115.25
7.0.50.0090.00615.32
7.0.40.0120.00313.76
7.0.30.0060.00613.52
7.0.20.0110.00413.55
7.0.10.0000.01613.61
7.0.00.0000.01313.63
5.6.400.0040.01214.36
5.6.390.0110.00414.49
5.6.380.0090.00614.61
5.6.370.0040.01114.76
5.6.360.0030.01314.43
5.6.350.0040.00714.80
5.6.340.0070.00714.65
5.6.330.0030.00914.71
5.6.320.0070.00714.46
5.6.310.0120.00314.58
5.6.300.0000.01314.72
5.6.290.0120.00314.91
5.6.280.0000.01414.70
5.6.270.0070.00714.45
5.6.260.0060.00914.67
5.6.250.0000.01514.87
5.6.240.0130.00714.50
5.6.230.0080.00414.65
5.6.220.0060.00614.33
5.6.210.0070.00414.45
5.6.200.0060.00614.57
5.6.190.0060.00614.44
5.6.180.0070.00714.49
5.6.170.0080.00414.43
5.6.160.0030.01414.68
5.6.150.0100.00714.23
5.6.140.0030.01214.39
5.6.130.0000.01714.45
5.6.120.0070.00714.28
5.6.110.0100.00314.34
5.6.100.0050.00514.68
5.6.90.0000.01314.43
5.6.80.0030.01114.41
5.6.70.0060.00914.31
5.6.60.0090.00314.77
5.6.50.0000.01614.61
5.6.40.0070.01014.50
5.6.30.0060.01014.43
5.6.20.0070.00714.46
5.6.10.0030.00914.11
5.6.00.0000.01414.59

preferences:
65.96 ms | 401 KiB | 5 Q