3v4l.org

run code in 500+ PHP versions simultaneously
<?php $first = [ 1 => 4.00, 2 => 3.00, 3 => 8.00, 4 => 4.88, 5 => 7.88, 10 => 17.88 ]; $second = [ 1 => 2.00, 3 => 4.00, 4 => 2.88, 7 => 5.0, 8 => 6.00 ]; // Merge the 2 original arrays and preserve the keys // https://stackoverflow.com/q/17462354/296555 // The duplicate items' value will be clobbered at this point but we don't care. We'll set them in the `array_walk` function. $output = $first + $second; // Create an array of the duplicates. We'll use these keys to calculate the difference. $both = array_intersect_key($first, $second); // Foreach element in the duplicates, calculate the difference. // Notice that we're passing in `&$output` by reference so that we are modifying the underlying object and not just a copy of it. array_walk($both, function($value, $key) use (&$output, $first, $second) { $output[$key] = $first[$key] - $second[$key]; }); // Finally, sort the final array by its keys. ksort($output); var_dump($output); // Output //array (size=8) // 1 => float 2 // 2 => float 3 // 3 => float 4 // 4 => float 2 // 5 => float 7.88 // 7 => float 5 // 8 => float 6 // 10 => float 17.88

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.5.30.0100.00918.90
8.5.20.0110.00819.46
8.5.10.0100.00818.36
8.5.00.0110.00920.18
8.4.180.0130.01021.95
8.4.170.0120.01023.82
8.4.160.0130.00923.60
8.4.150.0060.00716.90
8.4.140.0140.00717.54
8.4.130.0100.01017.57
8.4.120.0040.00420.53
8.4.110.0040.00520.37
8.4.100.0160.00617.92
8.4.90.0100.00720.35
8.4.80.0100.01019.07
8.4.70.0070.00118.87
8.4.60.0120.00619.07
8.4.50.0100.00818.66
8.4.40.0030.00619.39
8.4.30.0090.01020.40
8.4.20.0110.00018.95
8.4.10.0090.00019.61
8.3.300.0080.01422.58
8.3.290.0100.01018.49
8.3.280.0160.00820.25
8.3.270.0130.00816.76
8.3.260.0110.00516.54
8.3.250.0140.00318.76
8.3.240.0110.00617.06
8.3.230.0030.00516.43
8.3.220.0060.00218.86
8.3.210.0130.00616.78
8.3.200.0040.00516.77
8.3.190.0030.00617.34
8.3.180.0120.00819.02
8.3.170.0090.00917.28
8.3.160.0070.01116.82
8.3.150.0100.01017.31
8.3.140.0120.00316.80
8.3.130.0090.00616.50
8.3.120.0160.00320.70
8.3.110.0000.00920.94
8.3.100.0030.01024.06
8.3.90.0050.00826.77
8.3.80.0060.00316.63
8.3.70.0110.01116.58
8.3.60.0110.00718.18
8.3.50.0100.00921.95
8.3.40.0040.01118.97
8.3.30.0070.00718.75
8.3.20.0050.00322.23
8.3.10.0030.00521.80
8.3.00.0030.00622.39
8.2.300.0130.00818.11
8.2.290.0130.00616.84
8.2.280.0140.00518.74
8.2.270.0090.00616.86
8.2.260.0000.00916.79
8.2.250.0030.00618.66
8.2.240.0040.00419.07
8.2.230.0000.01022.58
8.2.220.0030.00537.54
8.2.210.0090.00026.77
8.2.200.0060.00316.38
8.2.190.0070.00716.63
8.2.180.0000.01518.54
8.2.170.0140.00722.96
8.2.160.0070.01422.25
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0000.00820.93
8.2.110.0000.00922.28
8.2.100.0120.00019.63
8.2.90.0040.00418.16
8.2.80.0090.00018.03
8.2.70.0060.00318.05
8.2.60.0060.00318.20
8.2.50.0090.00018.10
8.2.40.0030.00521.07
8.2.30.0040.00419.37
8.2.20.0030.00618.04
8.2.10.0000.00719.24
8.2.00.0050.00319.25
8.1.340.0130.00717.68
8.1.330.0100.01016.27
8.1.320.0100.00818.08
8.1.310.0030.00517.50
8.1.300.0030.00619.93
8.1.290.0110.00018.88
8.1.280.0140.00725.92
8.1.270.0060.00322.13
8.1.260.0070.00726.35
8.1.250.0050.00328.09
8.1.240.0000.00822.15
8.1.230.0110.00322.69
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0080.00417.48
8.1.190.0000.00817.35
8.1.180.0000.01118.10
8.1.170.0060.00318.71
8.1.160.0050.00518.91
8.1.150.0040.00418.77
8.1.140.0070.00020.89
8.1.130.0030.00320.15
8.1.120.0040.00417.50
8.1.110.0050.00317.43
8.1.100.0040.00417.48
8.1.90.0070.00317.48
8.1.80.0000.00817.54
8.1.70.0030.00517.48
8.1.60.0030.00517.64
8.1.50.0080.00017.53
8.1.40.0040.00417.40
8.1.30.0040.00417.67
8.1.20.0030.00517.72
8.1.10.0000.00817.61
8.1.00.0040.00417.54
8.0.300.0050.00321.50
8.0.290.0040.00416.88
8.0.280.0070.00018.50
8.0.270.0050.00317.27
8.0.260.0030.00620.29
8.0.250.0040.00417.06
8.0.240.0000.00717.02
8.0.230.0000.00717.06
8.0.220.0030.00316.90
8.0.210.0000.00716.97
8.0.200.0030.00317.03
8.0.190.0000.00716.97
8.0.180.0040.00416.88
8.0.170.0030.00616.94
8.0.160.0050.00216.92
8.0.150.0000.00816.98
8.0.140.0070.00016.95
8.0.130.0030.00313.35
8.0.120.0040.00416.92
8.0.110.0000.00716.83
8.0.100.0040.00416.91
8.0.90.0060.00316.78
8.0.80.0070.00716.93
8.0.70.0070.00016.83
8.0.60.0070.00016.82
8.0.50.0040.00416.78
8.0.30.0080.01417.08
8.0.20.0100.01016.90
8.0.10.0040.00417.08
8.0.00.0070.01116.63
7.4.330.0000.00515.55
7.4.320.0030.00316.57
7.4.300.0070.00016.56
7.4.290.0000.00716.60
7.4.280.0040.00416.49
7.4.270.0070.00016.53
7.4.260.0000.00613.29
7.4.250.0040.00416.47
7.4.240.0000.00716.64
7.4.230.0000.00716.67
7.4.220.0020.00416.42
7.4.210.0090.00616.58
7.4.200.0000.00716.56
7.4.130.0180.00716.54
7.4.120.0050.01516.57
7.4.110.0170.00716.64
7.4.100.0060.01516.60
7.4.90.0070.01116.50
7.4.80.0030.01319.39
7.4.70.0120.00616.53
7.4.60.0060.00916.57
7.4.50.0000.01116.33
7.4.40.0140.00316.56
7.4.10.0120.00614.97
7.4.00.0050.01015.02
7.3.330.0020.00516.39
7.3.320.0000.00513.44
7.3.310.0040.00416.22
7.3.300.0000.00616.24
7.3.290.0050.00216.32
7.3.280.0000.01516.19
7.3.260.0100.01016.51
7.3.240.0130.00616.47
7.3.230.0130.00716.65
7.3.210.0100.00816.60
7.3.200.0160.00016.68
7.3.190.0120.00516.70
7.3.180.0080.00816.31
7.3.170.0000.01716.41
7.3.160.0060.00916.66
7.3.130.0060.01314.66
7.3.120.0060.01214.92
7.3.110.0040.01114.88
7.3.100.0060.00814.86
7.3.90.0040.01114.82
7.3.80.0060.00914.84
7.3.70.0090.00514.80
7.3.60.0040.00814.78
7.3.50.0050.00914.75
7.3.40.0040.01014.71
7.3.30.0070.00814.72
7.3.20.0130.00915.65
7.3.10.0100.01015.78
7.3.00.0140.00415.69
7.2.330.0140.00516.74
7.2.320.0080.00816.69
7.2.310.0160.00016.57
7.2.300.0080.00816.70
7.2.290.0030.01216.77
7.2.260.0110.00714.93
7.2.250.0030.01015.18
7.2.240.0050.01015.03
7.2.230.0020.01215.08
7.2.220.0080.00415.04
7.2.210.0060.01014.93
7.2.200.0080.00715.07
7.2.190.0070.01015.11
7.2.180.0050.01215.00
7.2.170.0040.01314.90
7.2.160.0070.00915.09
7.2.150.0130.01016.00
7.2.140.0110.01015.96
7.2.130.0150.00516.01
7.2.120.0100.00815.97
7.2.110.0130.00615.98
7.2.100.0130.00415.97
7.2.90.0160.00615.99
7.2.80.0130.00616.03
7.2.70.0110.00715.95
7.2.60.0110.00716.02
7.2.50.0160.00516.07
7.2.40.0110.00716.12
7.2.30.0130.01015.98
7.2.20.0110.00716.06
7.2.10.0110.00916.02
7.2.00.0120.00915.99
7.1.330.0070.00715.88
7.1.320.0050.01015.73
7.1.310.0250.00814.89
7.1.300.0100.00714.87
7.1.290.0100.00914.93
7.1.280.0130.00814.82
7.1.270.0140.00714.67
7.1.260.0110.00814.97
7.1.250.0120.00614.94
7.1.240.0050.00515.70
7.1.230.0090.00315.64
7.1.220.0000.01215.64
7.1.210.0070.00716.00
7.1.200.0040.00816.00
7.1.190.0070.00715.82
7.1.180.0000.01515.88
7.1.170.0080.00416.01
7.1.160.0040.00815.80
7.1.150.0000.00915.70
7.1.140.0060.00615.99
7.1.130.0040.00815.77
7.1.120.0000.00815.71
7.1.110.0000.00915.98
7.1.100.0090.00315.92
7.1.90.0080.00315.55
7.1.80.0000.01315.71
7.1.70.0070.00415.94
7.1.60.0090.00315.71
7.1.50.0110.00315.89
7.1.40.0110.00415.63
7.1.30.0030.00615.83
7.1.20.0080.00515.80
7.1.10.0030.01015.67
7.1.00.0030.00915.84

preferences:
123.99 ms | 1655 KiB | 5 Q