3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates[] = array("date" => "2016-02-18 02:00:00", "duration" => "600"); // 10 mins $dates[] = array("date" => "2016-02-18 02:05:00", "duration" => "300"); // 5 mins $dates[] = array("date" => "2016-02-18 02:10:00", "duration" => "600"); $dates[] = array("date" => "2016-02-18 02:25:00", "duration" => "300"); $dates[] = array("date" => "2016-02-18 02:30:00", "duration" => "600"); $children = array("callum" => "1028", "daniel" => "1029"); $closeDate[] = array("date" => "2016-02-18 02:00:00", "duration" => "600"); // 10 mins function returnClosestDate($child){ global $initialLoop; global $closeDate; global $dates; foreach ($dates as $key => $date) { $dateToCompare = strtotime($date); $diff = $firstTime - $dateToCompare; if ($diff < 0) $diff *= -1; if (count($closeDate) == 0) { $closeDate[][$child] = array("date" => $date, "diff" => $diff); continue; } for ($x = 0; $x <= count($closeDate); $x++) { if(isset($closeDate[$x])){ if ($diff < $closeDate[$x][$child]["diff"]) { $closeDate[$x][$child] = array("date" => $date, "diff" => $diff); } } } //if(!alreadyExistInArray($closeDate, $date, $child)){ //if ($diff < $closeDate[$key-1]["diff"]) { //$closeDate[$key] = array("child" => $child, "date" => $date, "diff" => $diff); // } //} } echo "<pre>"; print_r($closeDate); echo "</pre>"; exit; } function alreadyExistInArray($closeDate, $date, $child){ foreach($closeDate as $key => $close){ if($close["child"] === $child) return true; } } foreach($children as $key => $child){ returnClosestDate($child); }

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.00316.88
8.3.50.0070.00718.08
8.3.40.0080.00818.96
8.3.30.0080.00819.00
8.3.20.0080.00020.64
8.3.10.0050.00321.56
8.3.00.0040.00421.60
8.2.180.0150.00617.00
8.2.170.0090.00622.96
8.2.160.0100.00322.25
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00019.95
8.2.120.0080.00026.35
8.2.110.0030.00721.12
8.2.100.0080.00417.84
8.2.90.0000.00819.17
8.2.80.0000.00817.97
8.2.70.0080.00017.63
8.2.60.0050.00317.93
8.2.50.0000.00818.10
8.2.40.0060.00320.59
8.2.30.0040.00419.41
8.2.20.0000.00718.16
8.2.10.0000.00819.81
8.2.00.0050.00217.73
8.1.280.0030.01925.92
8.1.270.0040.00422.09
8.1.260.0080.00028.09
8.1.250.0050.00228.09
8.1.240.0060.00323.92
8.1.230.0220.00617.53
8.1.220.0050.00317.91
8.1.210.0090.00018.77
8.1.200.0040.00417.35
8.1.190.0050.00317.35
8.1.180.0000.00818.10
8.1.170.0030.00618.59
8.1.160.0070.00023.92
8.1.150.0000.00921.95
8.1.140.0000.00719.66
8.1.130.0050.00317.61
8.1.120.0000.00717.39
8.1.110.0050.00317.49
8.1.100.0000.00817.50
8.1.90.0000.00717.53
8.1.80.0040.00417.51
8.1.70.0000.00717.48
8.1.60.0030.00617.66
8.1.50.0060.00317.50
8.1.40.0030.00617.55
8.1.30.0000.00817.71
8.1.20.0020.00517.66
8.1.10.0030.00517.57
8.1.00.0000.00717.59
8.0.300.0050.00218.77
8.0.290.0000.00916.75
8.0.280.0050.00318.43
8.0.270.0030.00317.29
8.0.260.0030.00317.29
8.0.250.0030.00316.96
8.0.240.0030.00316.91
8.0.230.0030.00516.97
8.0.220.0000.00717.00
8.0.210.0000.00716.91
8.0.200.0000.00716.94
8.0.190.0070.00316.95
8.0.180.0000.00817.04
8.0.170.0000.00716.97
8.0.160.0000.00717.00
8.0.150.0000.00716.91
8.0.140.0040.00416.97
8.0.130.0050.00013.45
8.0.120.0030.00616.98
8.0.110.0030.00516.98
8.0.100.0000.00716.94
8.0.90.0070.00016.80
8.0.80.0030.01316.92
8.0.70.0040.00417.02
8.0.60.0040.00416.77
8.0.50.0040.00416.89
8.0.30.0130.00617.14
8.0.20.0100.01017.40
8.0.10.0070.00017.17
8.0.00.0070.01016.73
7.4.330.0060.00015.55
7.4.320.0030.00316.56
7.4.300.0030.00316.56
7.4.290.0040.00416.51
7.4.280.0040.00416.43
7.4.270.0030.00316.61
7.4.260.0030.00716.50
7.4.250.0000.00816.60
7.4.240.0000.00816.56
7.4.230.0000.00716.35
7.4.220.0160.00316.55
7.4.210.0110.00616.57
7.4.200.0000.00716.65
7.4.160.0090.00716.51
7.4.150.0120.00617.40
7.4.140.0080.00917.86
7.4.130.0090.01016.46
7.4.120.0080.00916.63
7.4.110.0040.01316.60
7.4.100.0140.00316.61
7.4.90.0070.01316.53
7.4.80.0070.01119.39
7.4.70.0160.00616.68
7.4.60.0090.00616.61
7.4.50.0030.01316.17
7.4.40.0070.01116.23
7.4.30.0000.01616.54
7.4.00.0090.00814.99
7.3.330.0050.00013.30
7.3.320.0000.00513.45
7.3.310.0070.00016.39
7.3.300.0040.00416.45
7.3.290.0080.00816.44
7.3.280.0080.00916.47
7.3.270.0090.01217.40
7.3.260.0040.01316.53
7.3.250.0150.00516.62
7.3.240.0090.00916.59
7.3.230.0110.00616.40
7.3.210.0170.00016.41
7.3.200.0100.00716.73
7.3.190.0110.00616.57
7.3.180.0120.00916.42
7.3.170.0030.01616.60
7.3.160.0170.00616.36
7.3.120.0080.01014.79
7.3.110.0090.01014.82
7.3.100.0090.00914.89
7.3.90.0060.01114.77
7.3.80.0070.00915.05
7.3.70.0060.00814.77
7.3.60.0070.00514.88
7.3.50.0050.00714.78
7.3.40.0050.00714.63
7.3.30.0030.01214.79
7.3.20.0050.01116.67
7.3.10.0040.00816.73
7.3.00.0050.00816.70
7.2.330.0030.01916.83
7.2.320.0090.00916.83
7.2.310.0180.00316.54
7.2.300.0120.00616.68
7.2.290.0130.00316.78
7.2.250.0030.01415.17
7.2.240.0080.00915.30
7.2.230.0070.00915.08
7.2.220.0060.00814.95
7.2.210.0070.00715.18
7.2.200.0060.00815.18
7.2.190.0020.01315.12
7.2.180.0050.01015.06
7.2.170.0080.00515.16
7.2.130.0030.01016.84
7.2.120.0090.00616.91
7.2.110.0090.00616.71
7.2.100.0000.01117.04
7.2.90.0060.00917.05
7.2.80.0070.00717.03
7.2.70.0000.01117.14
7.2.60.0090.00516.94
7.2.50.0040.00816.98
7.2.40.0030.01416.79
7.2.30.0060.00916.75
7.2.20.0040.00817.11
7.2.10.0070.00416.97
7.2.00.0070.00818.01
7.1.330.0100.00315.89
7.1.320.0050.00515.91
7.1.310.0060.00815.79
7.1.300.0030.00815.77
7.1.290.0080.00315.75
7.1.280.0070.00715.82
7.1.270.0050.01015.67
7.1.260.0080.00515.86
7.1.250.0000.01415.66
7.1.200.0070.00415.66
7.1.100.0030.00718.13
7.1.70.0110.00317.10
7.1.60.0070.00717.12
7.1.00.0030.07722.27
7.0.200.0210.00314.64
7.0.120.0370.07720.34
7.0.110.0030.06722.11
7.0.100.0130.07322.00
7.0.90.0270.04722.20
7.0.80.0200.05722.02
7.0.70.0230.06722.11
7.0.60.0100.07322.00
7.0.50.0070.07022.09
7.0.40.0130.06322.13
7.0.30.0100.06322.04
7.0.20.0070.05722.03
7.0.10.0070.05321.98
7.0.00.0100.05321.96
5.6.270.0130.05321.07
5.6.260.0070.07720.94
5.6.250.0130.07020.83
5.6.240.0200.04720.77
5.6.230.0070.06021.05
5.6.220.0100.05720.86
5.6.210.0070.07020.99
5.6.200.0270.06321.08
5.6.190.0130.06720.82
5.6.180.0030.06021.00
5.6.170.0070.06020.90
5.6.160.0130.04720.94
5.6.150.0170.05021.02
5.6.140.0070.05720.85
5.6.130.0030.06320.79
5.6.120.0070.08020.76
5.6.110.0030.07020.94
5.6.100.0200.06321.06
5.6.90.0130.06720.73
5.6.80.0070.05020.41
5.6.70.0000.05720.40
5.6.60.0030.06320.38
5.6.50.0130.04320.22
5.6.40.0130.04320.39
5.6.30.0030.05720.15
5.6.20.0100.05320.21
5.6.10.0100.05320.12
5.6.00.0130.05020.15

preferences:
76.43 ms | 400 KiB | 5 Q