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.0110.00716.75
8.3.50.0060.01216.44
8.3.40.0090.01318.96
8.3.30.0040.01119.04
8.3.20.0040.00420.77
8.3.10.0000.00821.76
8.3.00.0070.00021.56
8.2.180.0140.01016.75
8.2.170.0120.00622.96
8.2.160.0060.00822.16
8.2.150.0040.00424.18
8.2.140.0020.00524.66
8.2.130.0080.00019.83
8.2.120.0080.00026.35
8.2.110.0030.00721.94
8.2.100.0130.00018.16
8.2.90.0030.00619.21
8.2.80.0040.00417.97
8.2.70.0000.00917.74
8.2.60.0060.00317.93
8.2.50.0050.00318.10
8.2.40.0080.00020.19
8.2.30.0100.00019.45
8.2.20.0040.00418.21
8.2.10.0070.00018.13
8.2.00.0050.00217.94
8.1.280.0040.01125.92
8.1.270.0000.00822.07
8.1.260.0000.00828.09
8.1.250.0070.00028.09
8.1.240.0040.00423.96
8.1.230.0070.00419.07
8.1.220.0040.00817.77
8.1.210.0030.00518.77
8.1.200.0060.00317.47
8.1.190.0090.00017.47
8.1.180.0000.00718.10
8.1.170.0000.00818.65
8.1.160.0000.00822.04
8.1.150.0000.00720.27
8.1.140.0000.00817.66
8.1.130.0070.00017.85
8.1.120.0040.00417.70
8.1.110.0030.00617.69
8.1.100.0050.00217.59
8.1.90.0040.00417.59
8.1.80.0000.00717.71
8.1.70.0000.00717.63
8.1.60.0080.00317.74
8.1.50.0000.00917.70
8.1.40.0040.00417.55
8.1.30.0040.00417.84
8.1.20.0040.00417.79
8.1.10.0040.00417.73
8.1.00.0000.00817.61
8.0.300.0080.00018.77
8.0.290.0060.00317.00
8.0.280.0030.00318.41
8.0.270.0000.00817.14
8.0.260.0030.00317.23
8.0.250.0000.00717.14
8.0.240.0070.00017.21
8.0.230.0000.00717.23
8.0.220.0070.00017.23
8.0.210.0050.00217.14
8.0.200.0040.00817.12
8.0.190.0070.00017.24
8.0.180.0000.00717.07
8.0.170.0060.00317.17
8.0.160.0000.00717.04
8.0.150.0030.00317.10
8.0.140.0000.00717.02
8.0.130.0030.00313.51
8.0.120.0040.00417.04
8.0.110.0030.00517.11
8.0.100.0030.00517.07
8.0.90.0040.00416.98
8.0.80.0060.01017.19
8.0.70.0000.00717.13
8.0.60.0000.00717.23
8.0.50.0050.00217.10
8.0.30.0080.01117.12
8.0.20.0130.00617.45
8.0.10.0040.00417.30
8.0.00.0090.00917.16
7.4.330.0000.00515.55
7.4.320.0030.00316.70
7.4.300.0040.00416.50
7.4.290.0050.00316.64
7.4.280.0050.00216.64
7.4.270.0000.00716.64
7.4.260.0050.00316.56
7.4.250.0030.00316.67
7.4.240.0000.00716.74
7.4.230.0000.00716.64
7.4.220.0100.01016.74
7.4.210.0090.01016.59
7.4.200.0030.00316.48
7.4.160.0050.01116.49
7.4.150.0120.00617.40
7.4.140.0080.01117.86
7.4.130.0060.01116.67
7.4.120.0080.00816.80
7.4.110.0060.01216.83
7.4.100.0100.01016.83
7.4.90.0090.00916.80
7.4.80.0110.00619.39
7.4.70.0160.00616.76
7.4.60.0120.00616.84
7.4.50.0070.00516.86
7.4.40.0130.00316.72
7.4.30.0080.00816.81
7.4.00.0100.00314.95
7.3.330.0000.00713.56
7.3.320.0030.00313.59
7.3.310.0000.00716.61
7.3.300.0040.00416.64
7.3.290.0080.00616.58
7.3.280.0100.00816.58
7.3.270.0150.00317.40
7.3.260.0090.01216.63
7.3.250.0070.01016.66
7.3.240.0070.01016.64
7.3.230.0100.01316.77
7.3.210.0090.00916.66
7.3.200.0050.01116.63
7.3.190.0160.00016.56
7.3.180.0140.00616.66
7.3.170.0070.01016.54
7.3.160.0030.01316.75
7.2.330.0120.00616.62
7.2.320.0130.00616.88
7.2.310.0090.00917.06
7.2.300.0080.00916.91
7.2.290.0090.00916.66
7.2.60.0130.00717.30
7.2.50.0070.00717.19
7.2.00.0070.00719.68
7.1.200.0060.00915.77
7.1.70.0000.01017.41
7.1.60.0040.01117.44
7.1.00.0030.07722.57
7.0.200.0250.01117.01
7.0.120.0300.04720.34
7.0.110.0100.06022.04
7.0.100.0100.05322.09
7.0.90.0130.05722.11
7.0.80.0030.06022.05
7.0.70.0130.05722.10
7.0.60.0130.05322.10
7.0.50.0100.06022.03
7.0.40.0070.05722.16
7.0.30.0100.05722.12
7.0.20.0130.06021.98
7.0.10.0030.06022.11
7.0.00.0100.05722.03
5.6.270.0030.06721.09
5.6.260.0100.05721.08
5.6.250.0070.05721.13
5.6.240.0170.05720.85
5.6.230.0200.04721.04
5.6.220.0100.05320.84
5.6.210.0170.05320.93
5.6.200.0030.06320.89
5.6.190.0170.05021.02
5.6.180.0070.06321.04
5.6.170.0130.05020.87
5.6.160.0230.05320.88
5.6.150.0070.06021.07
5.6.140.0030.06021.07
5.6.130.0000.06020.84
5.6.120.0030.06021.02
5.6.110.0070.05721.06
5.6.100.0030.06021.04
5.6.90.0070.05721.04
5.6.80.0030.05320.34
5.6.70.0170.04320.47
5.6.60.0100.05320.38
5.6.50.0130.05020.38
5.6.40.0170.04320.37
5.6.30.0130.04720.39
5.6.20.0000.06020.36
5.6.10.0030.05320.40
5.6.00.0030.05320.23

preferences:
74.01 ms | 401 KiB | 5 Q