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 = date_create("2018-10-25 00:00:00"); //mktime(0, 0, 0, 10, 25, 2018); $permit_active_date = date_create("2018-10-25 00:00:00"); $pay_frequency = "BW"; $UCDHS_MasterPaySchedule = array ( "BW" => array ( array ( "file_submit_date" => date_create("2018-09-14 00:00:00"), "pay_check_date" => date_create("2018-09-19 00:00:00"), "park_period_start" => date_create("2018-10-01 00:00:00"), "park_period_end" => date_create("2018-10-15 00:00:00"), "check_num" => 1 ), array ( "file_submit_date" => date_create("2018-09-28 00:00:00"), "pay_check_date" => date_create("2018-10-03 00:00:00"), "park_period_start" => date_create("2018-10-16 00:00:00"), "park_period_end" => date_create("2018-10-31 00:00:00"), "check_num" => 2 ), array ( "file_submit_date" => date_create("2018-10-12 00:00:00"), "pay_check_date" => date_create("2018-10-17 00:00:00"), "park_period_start" => date_create("2018-11-01 00:00:00"), "park_period_end" => date_create("2018-11-15 00:00:00"), "check_num" => 3 ), array ( "file_submit_date" => date_create("2018-11-08 00:00:00"), "pay_check_date" => date_create("2018-11-14 00:00:00"), "park_period_start" => date_create("2018-11-16 00:00:00"), "park_period_end" => date_create("2018-11-30 00:00:00"), "check_num" => 4 ), array ( "file_submit_date" => date_create("2018-11-21 00:00:00"), "pay_check_date" => date_create("2018-11-28 00:00:00"), "park_period_start" => date_create("2018-12-01 00:00:00"), "park_period_end" => date_create("2018-12-15 00:00:00"), "check_num" => 5 ), array ( "file_submit_date" => date_create("2018-12-07 00:00:00"), "pay_check_date" => date_create("2018-12-12 00:00:00"), "park_period_start" => date_create("2018-12-16 00:00:00"), "park_period_end" => date_create("2018-12-31 00:00:00"), "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 = ".date_format($permit_active_date,'Y-m-d')."\f\r"; echo "period['park_period_end'] = ".date_format($period["park_period_end"],'Y-m-d')."\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.40.0070.00718.96
8.3.30.0120.00318.92
8.3.20.0000.00919.45
8.3.10.0000.00723.52
8.3.00.0030.00520.71
8.2.170.0120.00322.96
8.2.160.0120.00320.36
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00319.89
8.2.120.0040.00426.35
8.2.110.0030.00619.27
8.2.100.0070.00418.02
8.2.90.0050.00318.09
8.2.80.0000.00818.05
8.2.70.0050.00317.93
8.2.60.0040.00418.16
8.2.50.0040.00418.10
8.2.40.0050.00319.61
8.2.30.0040.00419.48
8.2.20.0070.00018.30
8.2.10.0020.00518.33
8.2.00.0060.00317.92
8.1.270.0050.00320.85
8.1.260.0060.00326.35
8.1.250.0060.00928.09
8.1.240.0060.00617.76
8.1.230.0090.00321.04
8.1.220.0030.00618.03
8.1.210.0000.00818.84
8.1.200.0090.00017.60
8.1.190.0000.00817.38
8.1.180.0050.00318.10
8.1.170.0000.00818.96
8.1.160.0040.00420.66
8.1.150.0030.00519.05
8.1.140.0000.00822.11
8.1.130.0050.00320.25
8.1.120.0020.00517.71
8.1.110.0000.00817.63
8.1.100.0040.00417.77
8.1.90.0000.00817.73
8.1.80.0000.00717.74
8.1.70.0000.01017.54
8.1.60.0060.00617.70
8.1.50.0000.00817.74
8.1.40.0030.00917.59
8.1.30.0030.00617.75
8.1.20.0040.00417.69
8.1.10.0030.00617.83
8.1.00.0030.00617.61
8.0.300.0000.00719.89
8.0.290.0040.00417.00
8.0.280.0040.00418.50
8.0.270.0040.00417.49
8.0.260.0030.00318.57
8.0.250.0030.00717.19
8.0.240.0000.00717.25
8.0.230.0000.00717.21
8.0.220.0090.00016.98
8.0.210.0000.00717.04
8.0.200.0030.00317.19
8.0.190.0060.00317.24
8.0.180.0000.00817.22
8.0.170.0030.00617.17
8.0.160.0000.00717.04
8.0.150.0050.00217.05
8.0.140.0000.00717.09
8.0.130.0000.00613.54
8.0.120.0040.00417.09
8.0.110.0040.00417.16
8.0.100.0040.00416.97
8.0.90.0050.00317.20
8.0.80.0080.00817.08
8.0.70.0040.00417.04
8.0.60.0000.00716.99
8.0.50.0000.00816.94
8.0.30.0120.00617.49
8.0.20.0130.01017.48
8.0.10.0040.00417.13
8.0.00.0090.00817.13
7.4.330.0030.00315.55
7.4.320.0000.00716.71
7.4.300.0030.00516.59
7.4.290.0000.00716.79
7.4.280.0030.00616.63
7.4.270.0000.00716.60
7.4.260.0040.00216.57
7.4.250.0000.00816.76
7.4.240.0040.00416.72
7.4.230.0050.00216.79
7.4.220.0030.00616.81
7.4.210.0120.00316.71
7.4.200.0000.00716.88
7.4.160.0100.00816.65
7.4.140.0120.00917.86
7.4.130.0090.00916.99
7.4.120.0060.01316.73
7.4.110.0070.01016.71
7.4.100.0170.00716.74
7.4.90.0170.00416.67
7.4.80.0100.01519.39
7.4.70.0030.01316.83
7.4.60.0070.01016.78
7.4.50.0070.01016.83
7.4.40.0140.01116.90
7.4.10.0070.01215.92
7.4.00.0090.00915.62
7.3.330.0060.00013.55
7.3.320.0050.00013.50
7.3.310.0040.00416.49
7.3.300.0050.00216.46
7.3.290.0000.00716.51
7.3.280.0060.00916.61
7.3.260.0130.00916.71
7.3.240.0110.01016.69
7.3.230.0030.01316.56
7.3.210.0110.00516.79
7.3.200.0140.00316.80
7.3.190.0140.00516.82
7.3.180.0130.00716.63
7.3.170.0110.00716.82
7.3.160.0150.00616.75
7.3.130.0080.01115.82
7.3.120.0060.01115.54
7.3.110.0090.01015.51
7.3.100.0080.00915.63
7.3.90.0070.00815.59
7.3.80.0090.00815.60
7.3.70.0060.00715.58
7.3.60.0080.00615.46
7.3.50.0090.00415.59
7.3.40.0060.00915.50
7.3.30.0100.00615.42
7.3.20.0070.00617.39
7.3.10.0070.00817.15
7.3.00.0050.00817.21
7.2.330.0060.01817.05
7.2.320.0070.01116.86
7.2.310.0060.01217.02
7.2.300.0070.01016.96
7.2.290.0100.01317.04
7.2.260.0070.01316.07
7.2.250.0060.01515.99
7.2.240.0080.01015.84
7.2.230.0080.00616.03
7.2.220.0090.00515.85
7.2.210.0070.00815.70
7.2.200.0050.01115.79
7.2.190.0050.01015.76
7.2.180.0040.00715.85
7.2.170.0040.00915.88
7.2.160.0060.00615.91
7.2.150.0050.00917.69
7.2.140.0050.00917.89
7.2.130.0060.01017.60
7.2.120.0070.00617.69
7.2.110.0210.00916.98
7.2.100.0200.00716.86
7.2.90.0240.00617.01
7.2.80.0220.00817.01
7.2.70.0200.01017.06
7.2.60.0240.00817.06
7.2.50.0280.00716.99
7.2.40.0230.00917.03
7.2.30.0290.01316.98
7.2.20.0180.00916.96
7.2.10.0250.00516.96
7.2.00.0370.00817.02
7.1.330.0030.01216.46
7.1.320.0070.00616.60
7.1.310.0070.00916.51
7.1.300.0030.00916.41
7.1.290.0060.00616.46
7.1.280.0020.01016.46
7.1.270.0030.01016.48
7.1.260.0060.00716.45
7.1.250.0030.01016.51
7.1.240.0060.00716.78
7.1.230.0370.00715.88
7.1.220.0250.00815.91
7.1.210.0250.00715.78
7.1.200.0370.00715.85
7.1.190.0290.00815.73
7.1.180.0250.00715.74
7.1.170.0370.00815.86
7.1.160.0290.00815.73
7.1.150.0290.00715.83
7.1.140.0440.01015.92
7.1.130.0180.00815.73
7.1.120.0400.00515.86
7.1.110.0310.00715.87
7.1.100.0420.00815.90
7.1.90.0420.00715.94
7.1.80.0410.00415.94
7.1.70.0290.00715.95
7.1.60.0320.00821.85
7.1.50.0390.01021.90
7.1.40.0300.00821.94
7.1.30.0360.01221.87
7.1.20.0370.00821.86
7.1.10.0290.00915.85
7.1.00.0290.00515.94
7.0.330.0030.01016.38
7.0.320.0040.01216.33
7.0.310.0060.00916.29
7.0.300.0030.01216.25
7.0.290.0030.01116.33
7.0.280.0130.00216.32
7.0.270.0110.00416.34
7.0.260.0030.01016.39
7.0.250.0060.00616.33
7.0.240.0100.00516.45
7.0.230.0060.00616.42
7.0.220.0050.00816.33
7.0.210.0090.00516.48
7.0.200.0050.00916.40
7.0.190.0050.01416.32
7.0.180.0070.00716.43
7.0.170.0080.00716.44
7.0.160.0070.00916.36
7.0.150.0080.00816.29
7.0.140.0030.00916.47
7.0.130.0100.00616.21
7.0.120.0080.00716.36
7.0.110.0060.00816.21
7.0.100.0030.01016.37
7.0.90.0080.00616.44
7.0.80.0060.00616.44
7.0.70.0040.01016.53
7.0.60.0020.01216.16
7.0.50.0060.00716.40
7.0.40.0050.01214.25
7.0.30.0090.00514.31
7.0.20.0030.01114.40
7.0.10.0110.00614.40
7.0.00.0030.01014.40
5.6.400.0070.00715.39
5.6.390.0050.01115.21
5.6.380.0040.01015.29
5.6.370.0030.01215.43
5.6.360.0000.01615.21
5.6.350.0030.00915.46
5.6.340.0040.01315.69
5.6.330.0050.01015.42
5.6.320.0070.00715.33
5.6.310.0070.01015.50
5.6.300.0090.00615.27
5.6.290.0060.00815.39
5.6.280.0070.00715.44
5.6.270.0080.00915.50
5.6.260.0060.00915.47
5.6.250.0030.01315.26
5.6.240.0070.00815.23
5.6.230.0090.00615.43
5.6.220.0090.00715.28
5.6.210.0050.01315.39
5.6.200.0080.01115.32
5.6.190.0080.00615.26
5.6.180.0070.00815.25
5.6.170.0070.00815.27
5.6.160.0090.01015.30
5.6.150.0050.01015.32
5.6.140.0100.00815.36
5.6.130.0050.01115.40
5.6.120.0050.01015.45
5.6.110.0050.01015.58
5.6.100.0040.01115.50
5.6.90.0050.01115.31
5.6.80.0050.01215.44
5.6.70.0040.00915.13
5.6.60.0030.01015.33
5.6.50.0080.00715.30
5.6.40.0090.00515.25
5.6.30.0050.00715.36
5.6.20.0090.00515.21
5.6.10.0060.00915.31
5.6.00.0070.00715.56

preferences:
58.93 ms | 400 KiB | 5 Q