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[$key] = array("child" => $child, "date" => $date, "diff" => $diff); continue; } for ($x = 0; $x <= count($closeDate); $x++) { if ($diff < $closeDate[$x]["diff"]) { $closeDate[$x] = array("child" => $child, "date" => $date, "diff" => $diff); echo "<pre>"; print_r($closeDate); echo "</pre>"; exit; } } //if(!alreadyExistInArray($closeDate, $date, $child)){ //if ($diff < $closeDate[$key-1]["diff"]) { //$closeDate[$key] = array("child" => $child, "date" => $date, "diff" => $diff); // } //} } } 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.0160.00616.75
8.3.50.0150.00521.33
8.3.40.0090.00618.87
8.3.30.0090.00618.96
8.3.20.0080.00020.69
8.3.10.0030.00521.60
8.3.00.0040.00421.90
8.2.180.0120.00616.88
8.2.170.0040.01122.96
8.2.160.0070.00722.17
8.2.150.0030.00624.18
8.2.140.0030.00524.66
8.2.130.0040.00419.95
8.2.120.0040.00426.35
8.2.110.0070.00420.57
8.2.100.0080.00417.91
8.2.90.0050.00319.18
8.2.80.0000.00818.15
8.2.70.0100.00018.00
8.2.60.0000.00818.05
8.2.50.0040.00418.17
8.2.40.0030.00620.64
8.2.30.0000.01019.34
8.2.20.0040.00418.21
8.2.10.0020.00518.13
8.2.00.0040.00418.01
8.1.280.0130.00725.92
8.1.270.0040.00422.21
8.1.260.0070.00028.09
8.1.250.0070.00028.09
8.1.240.0050.00522.13
8.1.230.0060.00619.14
8.1.220.0030.00517.74
8.1.210.0080.00018.77
8.1.200.0060.00317.50
8.1.190.0040.00417.47
8.1.180.0000.01018.10
8.1.170.0030.00618.73
8.1.160.0030.00522.16
8.1.150.0030.00320.33
8.1.140.0000.00719.72
8.1.130.0000.00717.70
8.1.120.0000.00717.59
8.1.110.0040.00417.66
8.1.100.0050.00217.56
8.1.90.0040.00417.64
8.1.80.0080.00017.66
8.1.70.0060.00317.63
8.1.60.0030.00917.75
8.1.50.0040.00417.65
8.1.40.0000.00917.70
8.1.30.0050.00317.87
8.1.20.0040.00417.67
8.1.10.0040.00417.71
8.1.00.0060.00317.61
8.0.300.0060.00320.09
8.0.290.0040.00416.88
8.0.280.0030.00318.53
8.0.270.0030.00317.30
8.0.260.0000.00717.39
8.0.250.0070.00017.26
8.0.240.0030.00317.13
8.0.230.0030.00317.23
8.0.220.0030.00517.16
8.0.210.0070.00017.14
8.0.200.0030.00317.11
8.0.190.0000.01117.24
8.0.180.0040.00417.07
8.0.170.0040.00417.07
8.0.160.0030.00517.24
8.0.150.0030.00317.04
8.0.140.0030.00317.04
8.0.130.0030.00313.58
8.0.120.0060.00317.08
8.0.110.0040.00417.11
8.0.100.0040.00417.27
8.0.90.0060.00317.19
8.0.80.0100.01017.21
8.0.70.0000.00717.21
8.0.60.0070.00017.24
8.0.50.0040.00417.13
8.0.30.0110.00617.32
8.0.20.0110.00917.43
8.0.10.0000.00717.13
8.0.00.0060.01216.75
7.4.330.0050.00015.55
7.4.320.0000.00716.75
7.4.300.0000.00716.63
7.4.290.0030.00316.55
7.4.280.0040.00416.79
7.4.270.0030.00316.55
7.4.260.0000.00716.75
7.4.250.0030.00316.54
7.4.240.0020.00516.77
7.4.230.0070.00016.52
7.4.220.0150.00316.74
7.4.210.0120.00316.81
7.4.200.0000.00716.74
7.4.160.0060.01016.64
7.4.150.0110.01117.40
7.4.140.0130.00817.86
7.4.130.0120.00516.86
7.4.120.0090.00716.71
7.4.110.0060.01516.75
7.4.100.0090.01316.85
7.4.90.0060.01216.72
7.4.80.0100.00719.39
7.4.70.0150.00816.63
7.4.60.0030.01316.72
7.4.50.0060.00916.80
7.4.40.0000.01616.68
7.4.30.0070.01016.73
7.4.00.0100.00315.03
7.3.330.0030.00313.40
7.3.320.0020.00213.51
7.3.310.0000.00816.43
7.3.300.0000.00716.37
7.3.290.0080.00816.51
7.3.280.0090.00616.58
7.3.270.0120.00617.40
7.3.260.0140.00816.61
7.3.250.0090.00916.55
7.3.240.0100.00816.69
7.3.230.0150.00616.70
7.3.210.0030.01416.71
7.3.200.0060.01016.61
7.3.190.0100.01316.72
7.3.180.0120.00616.66
7.3.170.0140.00316.53
7.3.160.0030.01716.52
7.3.10.0160.00516.70
7.3.00.0130.00716.90
7.2.330.0130.00717.01
7.2.320.0040.01517.01
7.2.310.0030.01416.82
7.2.300.0060.01516.98
7.2.290.0030.01316.92
7.2.130.0080.00817.02
7.2.120.0070.01417.04
7.2.110.0120.00817.08
7.2.100.0120.00616.90
7.2.90.0070.01017.19
7.2.80.0050.01016.82
7.2.70.0090.00616.88
7.2.60.0110.00716.79
7.2.50.0080.01217.06
7.2.40.0140.00617.03
7.2.30.0000.01616.96
7.2.20.0090.00916.88
7.2.10.0110.00817.03
7.2.00.0080.01018.42
7.1.250.0110.00815.76
7.1.240.0100.01015.70
7.1.230.0130.00415.70
7.1.220.0080.01315.61
7.1.210.0100.01015.94
7.1.200.0150.00715.43
7.1.190.0130.00515.58
7.1.180.0140.00715.62
7.1.170.0100.00715.96
7.1.160.0100.00715.82
7.1.150.0110.00615.84
7.1.140.0070.01015.71
7.1.130.0110.00515.82
7.1.120.0120.00315.80
7.1.110.0140.00316.07
7.1.100.0120.00816.04
7.1.90.0110.00815.97
7.1.80.0130.00516.05
7.1.70.0090.00616.41
7.1.60.0070.01316.56
7.1.50.0120.00616.26
7.1.40.0050.00916.31
7.1.30.0080.00916.48
7.1.20.0100.00516.21
7.1.10.0070.00716.27
7.1.00.0050.00816.46
7.0.330.0110.00715.32
7.0.320.0130.00915.31
7.0.310.0120.00615.50
7.0.300.0120.00615.16
7.0.290.0030.01215.41
7.0.280.0070.01015.23
7.0.270.0170.00015.21
7.0.260.0090.00915.54
7.0.250.0130.00315.50
7.0.240.0070.00715.13
7.0.230.0040.01115.49
7.0.220.0150.00415.37
7.0.210.0030.01215.28
7.0.200.0030.01116.22
7.0.190.0050.01016.20
7.0.180.0070.00616.06
7.0.170.0080.00516.21
7.0.160.0070.00716.23
7.0.150.0080.00716.21
7.0.140.0080.00416.25
7.0.130.0060.01116.11
7.0.120.0070.01016.20
7.0.110.0070.01016.21
7.0.100.0080.00416.14
7.0.90.0050.00916.19
7.0.80.0100.00416.01
7.0.70.0060.00916.21
7.0.60.0060.00916.14
7.0.50.0080.00416.26
7.0.40.0050.00715.23
7.0.30.0060.00615.13
7.0.20.0080.00514.83
7.0.10.0040.00715.18
7.0.00.0060.00715.17
5.6.380.0140.00314.07
5.6.370.0070.00214.82
5.6.360.0080.00514.48
5.6.350.0110.00414.35
5.6.340.0060.01114.54
5.6.330.0080.00814.15
5.6.320.0090.00814.70
5.6.310.0000.01014.55
5.6.300.0060.02517.57
5.6.290.0060.02317.85
5.6.280.0040.02517.79
5.6.270.0070.02317.64
5.6.260.0060.04417.73
5.6.250.0060.02417.60
5.6.240.0070.02517.71
5.6.230.0070.02517.72
5.6.220.0030.03817.63
5.6.210.0090.03417.63
5.6.200.0030.03617.63
5.6.190.0070.02517.81
5.6.180.0060.02517.82
5.6.170.0070.02817.65
5.6.160.0070.02317.70
5.6.150.0030.03517.63
5.6.140.0060.04317.63
5.6.130.0090.03717.75
5.6.120.0050.03417.48
5.6.110.0090.02717.77
5.6.100.0080.02717.66
5.6.90.0060.02817.73
5.6.80.0070.02317.31
5.6.70.0050.02817.40
5.6.60.0090.02217.22
5.6.50.0080.04317.24
5.6.40.0110.04117.31
5.6.30.0110.03917.49
5.6.20.0050.04417.45
5.6.10.0100.02417.40
5.6.00.0120.02217.32

preferences:
59.86 ms | 401 KiB | 5 Q