3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = array("2012-06-11 08:30:49", "2012-06-07 08:03:54", "2012-05-26 23:04:04", "2012-05-27 08:30:00", "2012-06-08 08:30:55", "2012-06-12 07:45:45"); $children = array("callum" => "1028", "daniel" => "1029"); $closeDate = array(); $firstDate = strtotime("2012-05-29 07:45:45"); function returnClosestDate($firstTime, $dates, $child){ global $initialLoop; global $closeDate; 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($firstDate, $dates, $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.0120.00316.88
8.3.50.0100.01018.20
8.3.40.0110.00419.13
8.3.30.0070.00718.98
8.3.20.0000.00819.16
8.3.10.0000.00721.90
8.3.00.0040.00421.70
8.2.180.0170.00317.00
8.2.170.0070.01022.96
8.2.160.0140.00022.17
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0050.00319.95
8.2.120.0080.00026.35
8.2.110.0030.00621.98
8.2.100.0110.00017.97
8.2.90.0050.00519.23
8.2.80.0000.00818.17
8.2.70.0070.00317.88
8.2.60.0080.00018.16
8.2.50.0050.00318.16
8.2.40.0070.00020.42
8.2.30.0060.00319.39
8.2.20.0000.00718.14
8.2.10.0080.00018.32
8.2.00.0060.00318.02
8.1.280.0070.01325.92
8.1.270.0040.00422.05
8.1.260.0100.00028.09
8.1.250.0000.00728.09
8.1.240.0080.00023.79
8.1.230.0100.00022.21
8.1.220.0040.00417.78
8.1.210.0050.00318.77
8.1.200.0000.00917.47
8.1.190.0030.00617.60
8.1.180.0080.00018.10
8.1.170.0040.00418.65
8.1.160.0070.00023.94
8.1.150.0040.00422.10
8.1.140.0040.00419.72
8.1.130.0050.00217.69
8.1.120.0040.00417.68
8.1.110.0000.00817.65
8.1.100.0040.00417.65
8.1.90.0000.00817.70
8.1.80.0040.00417.69
8.1.70.0000.00817.57
8.1.60.0040.00417.71
8.1.50.0040.00417.63
8.1.40.0040.00417.65
8.1.30.0030.00617.80
8.1.20.0030.00517.78
8.1.10.0080.00017.63
8.1.00.0040.00417.69
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.53
8.0.270.0040.00417.35
8.0.260.0030.00317.34
8.0.250.0000.00717.19
8.0.240.0030.00317.22
8.0.230.0070.00017.20
8.0.220.0030.00317.15
8.0.210.0070.00017.05
8.0.200.0000.00617.25
8.0.190.0020.00817.28
8.0.180.0000.00717.21
8.0.170.0040.00417.10
8.0.160.0070.00017.19
8.0.150.0000.00817.06
8.0.140.0000.00717.02
8.0.130.0000.00613.52
8.0.120.0000.00817.06
8.0.110.0030.00517.13
8.0.100.0040.00417.14
8.0.90.0000.00817.22
8.0.80.0170.00317.16
8.0.70.0040.00417.21
8.0.60.0040.00417.05
8.0.50.0040.00417.05
8.0.30.0120.00617.24
8.0.20.0110.00917.41
8.0.10.0050.00317.13
8.0.00.0090.00917.05
7.4.330.0000.00715.55
7.4.320.0000.00616.64
7.4.300.0060.00016.71
7.4.290.0000.00816.66
7.4.280.0000.00916.67
7.4.270.0030.00316.73
7.4.260.0040.00416.71
7.4.250.0060.00316.57
7.4.240.0000.00716.66
7.4.230.0030.00516.84
7.4.220.0100.01716.80
7.4.210.0100.01016.59
7.4.200.0030.00316.53
7.4.160.0100.00516.60
7.4.150.0070.01017.40
7.4.140.0060.01417.86
7.4.130.0070.01016.73
7.4.120.0110.00616.73
7.4.110.0100.01016.79
7.4.100.0090.00916.73
7.4.90.0130.00616.64
7.4.80.0060.01219.39
7.4.70.0030.01616.86
7.4.60.0000.01616.72
7.4.50.0090.00616.87
7.4.40.0090.00916.73
7.4.30.0090.00616.86
7.4.10.0070.01015.18
7.4.00.0040.01315.09
7.3.330.0000.00513.54
7.3.320.0000.00513.54
7.3.310.0040.00416.62
7.3.300.0030.00316.42
7.3.290.0060.00816.57
7.3.280.0070.01116.59
7.3.270.0090.00917.40
7.3.260.0060.01216.73
7.3.250.0100.01016.63
7.3.240.0080.01016.77
7.3.230.0140.00316.70
7.3.210.0140.00316.73
7.3.200.0000.01716.68
7.3.190.0060.01516.69
7.3.180.0140.00716.66
7.3.170.0060.01216.78
7.3.160.0210.00016.61
7.3.130.0070.01015.11
7.3.120.0140.00515.19
7.3.110.0120.00715.12
7.3.100.0060.00815.01
7.3.90.0030.00815.09
7.3.80.0080.00514.96
7.3.70.0060.00715.06
7.3.60.0090.00415.12
7.3.50.0050.00815.05
7.3.40.0080.00514.97
7.3.30.0050.00714.95
7.3.20.0070.00516.99
7.3.10.0030.01016.70
7.3.00.0080.00816.84
7.2.330.0090.01316.90
7.2.320.0100.01016.63
7.2.310.0080.00816.84
7.2.300.0200.00317.04
7.2.290.0060.00917.03
7.2.260.0070.01315.20
7.2.250.0090.00915.22
7.2.240.0060.00915.30
7.2.230.0040.01115.02
7.2.220.0060.00815.25
7.2.210.0070.01115.40
7.2.200.0070.00815.30
7.2.190.0120.00215.33
7.2.180.0040.01115.32
7.2.170.0030.01215.29
7.2.160.0060.00915.29
7.2.150.0000.01617.13
7.2.140.0120.00017.21
7.2.130.0120.00617.13
7.2.120.0040.00717.16
7.2.110.0130.00017.11
7.2.100.0140.00017.26
7.2.90.0060.00617.17
7.2.80.0040.01117.06
7.2.70.0040.01117.06
7.2.60.0100.00617.13
7.2.50.0040.01117.05
7.2.40.0040.00717.10
7.2.30.0090.00917.15
7.2.20.0000.01317.22
7.2.10.0090.00616.96
7.2.00.0050.00718.51
7.1.330.0080.00815.96
7.1.320.0030.01215.93
7.1.310.0070.00816.05
7.1.300.0060.00615.92
7.1.290.0050.00916.05
7.1.280.0100.00515.59
7.1.270.0050.01216.09
7.1.260.0050.01015.77
7.1.250.0040.00716.03
7.1.240.0070.01016.16
7.1.230.0060.00915.81
7.1.220.0090.00615.86
7.1.210.0110.00016.06
7.1.200.0100.00315.84
7.1.190.0070.00716.14
7.1.180.0070.00716.09
7.1.170.0070.00715.99
7.1.160.0000.01415.96
7.1.150.0000.01015.90
7.1.140.0080.00815.87
7.1.130.0000.01316.09
7.1.120.0080.00415.71
7.1.110.0060.00916.02
7.1.100.0000.01416.20
7.1.90.0070.00315.96
7.1.80.0140.00016.08
7.1.70.0030.00716.52
7.1.60.0060.00616.64
7.1.50.0060.00616.08
7.1.40.0100.00715.84
7.1.30.0090.00415.96
7.1.20.0090.00615.87
7.1.10.0030.01016.02
7.1.00.0020.04319.05
7.0.330.0080.00815.44
7.0.320.0060.00915.54
7.0.310.0040.00415.51
7.0.300.0000.00915.60
7.0.290.0110.00415.58
7.0.280.0030.00615.75
7.0.270.0040.00815.20
7.0.260.0040.01015.43
7.0.250.0110.00415.32
7.0.240.0050.00315.59
7.0.230.0090.00415.73
7.0.220.0070.00715.28
7.0.210.0070.00415.68
7.0.200.0120.00916.00
7.0.190.0030.01015.32
7.0.180.0040.00815.66
7.0.170.0070.00715.73
7.0.160.0060.00815.43
7.0.150.0000.01315.43
7.0.140.0060.00915.67
7.0.130.0040.00415.54
7.0.120.0070.02918.85
7.0.110.0060.03118.85
7.0.100.0030.03218.77
7.0.90.0120.03218.85
7.0.80.0100.03818.69
7.0.70.0070.04218.91
7.0.60.0020.03718.81
7.0.50.0050.03318.92
7.0.40.0080.02917.82
7.0.30.0090.03017.78
7.0.20.0100.02817.86
7.0.10.0020.03717.87
7.0.00.0080.03017.86
5.6.400.0130.00314.47
5.6.390.0100.00614.79
5.6.380.0080.00814.54
5.6.370.0000.00914.86
5.6.360.0100.00714.49
5.6.350.0090.00614.43
5.6.340.0080.00414.33
5.6.330.0040.00714.41
5.6.320.0000.01214.45
5.6.310.0070.00914.72
5.6.300.0030.01314.80
5.6.290.0060.00314.80
5.6.280.0110.00414.65
5.6.270.0120.02817.87
5.6.260.0090.03217.70
5.6.250.0080.03217.75
5.6.240.0030.03617.63
5.6.230.0080.03317.73
5.6.220.0100.03217.88
5.6.210.0120.02517.80
5.6.200.0070.03317.85
5.6.190.0090.03117.78
5.6.180.0080.02817.73
5.6.170.0050.03217.65
5.6.160.0050.03217.98
5.6.150.0060.03117.77
5.6.140.0100.03017.82
5.6.130.0050.03317.69
5.6.120.0050.03617.88
5.6.110.0120.03817.78
5.6.100.0070.03417.72
5.6.90.0080.03117.79
5.6.80.0050.03217.51
5.6.70.0080.03117.25
5.6.60.0060.03617.34
5.6.50.0110.02817.33
5.6.40.0030.03417.38
5.6.30.0080.03217.49
5.6.20.0070.03017.45
5.6.10.0130.03317.20
5.6.00.0070.03317.36

preferences:
39.35 ms | 400 KiB | 5 Q