3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'code 10 and amount 1000', 'code 10 and amount 200', 'code 10 and amount 300', 'code 20 and amount 2000' ); $output = array(); foreach ($array as $value) { // Extract the values from the string preg_match('/^code\s(.*)\s\sand amount\s(.*)$/', $value, $match); // If no code exists, we have a problem so skip the line if (! isset($match[1])) { continue; } // Make this a bit more readable for future devs $code = (int) $match[1]; $amount = (int) isset($match[2]) ? $match[2] : 0; // If the code exists in the output array, add the value to it if (isset($output[$code])) { $output[$code] += $amount; } else { // Else make the new code have the value $output[$code] = $amount; } } print_r($output);

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.0090.00618.77
8.3.50.0110.00921.21
8.3.40.0070.01118.82
8.3.30.0080.00619.07
8.3.20.0080.00020.34
8.3.10.0020.00522.15
8.3.00.0050.00322.52
8.2.180.0120.00416.75
8.2.170.0110.00422.96
8.2.160.0150.00020.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00426.16
8.2.120.0080.00019.77
8.2.110.0060.00320.47
8.2.100.0090.00317.84
8.2.90.0040.00419.17
8.2.80.0060.00318.00
8.2.70.0080.00017.88
8.2.60.0000.00818.03
8.2.50.0080.00018.07
8.2.40.0000.00818.34
8.2.30.0040.00418.09
8.2.20.0040.00417.93
8.2.10.0030.00617.91
8.2.00.0040.00417.82
8.1.280.0120.00325.92
8.1.270.0030.00620.54
8.1.260.0110.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00323.91
8.1.230.0030.01022.08
8.1.220.0030.00517.74
8.1.210.0090.00018.77
8.1.200.0090.00017.48
8.1.190.0040.00417.52
8.1.180.0060.00318.68
8.1.170.0060.00318.70
8.1.160.0040.00422.18
8.1.150.0040.00418.83
8.1.140.0030.00517.52
8.1.130.0000.00717.80
8.1.120.0040.00417.63
8.1.110.0040.00417.52
8.1.100.0070.00017.64
8.1.90.0000.00717.67
8.1.80.0000.00717.66
8.1.70.0030.00317.63
8.1.60.0040.00417.63
8.1.50.0040.00417.75
8.1.40.0040.00417.67
8.1.30.0090.00017.67
8.1.20.0040.00417.86
8.1.10.0030.00617.75
8.1.00.0070.00017.75
8.0.300.0000.00718.77
8.0.290.0000.00717.05
8.0.280.0030.00318.48
8.0.270.0030.00317.34
8.0.260.0070.00016.97
8.0.250.0070.00017.02
8.0.240.0040.00417.11
8.0.230.0000.00717.08
8.0.220.0000.00717.07
8.0.210.0070.00016.94
8.0.200.0030.00317.17
8.0.190.0050.00216.96
8.0.180.0040.00417.07
8.0.170.0050.00316.98
8.0.160.0000.00717.02
8.0.150.0050.00317.01
8.0.140.0050.00217.01
8.0.130.0030.00313.44
8.0.120.0040.00416.98
8.0.110.0000.00817.09
8.0.100.0000.00717.16
8.0.90.0040.00416.95
8.0.80.0140.00317.04
8.0.70.0050.00316.95
8.0.60.0040.00417.02
8.0.50.0080.00017.01
8.0.30.0110.00817.27
8.0.20.0060.01517.50
8.0.10.0040.00417.05
8.0.00.0060.01316.84
7.4.330.0000.00615.00
7.4.320.0000.00616.85
7.4.300.0000.00716.82
7.4.290.0030.00316.83
7.4.280.0030.00316.80
7.4.270.0000.00816.83
7.4.260.0000.00716.63
7.4.250.0070.00016.80
7.4.240.0000.00716.76
7.4.230.0030.00316.57
7.4.220.0140.01116.75
7.4.210.0060.00816.69
7.4.200.0000.00716.48
7.4.190.0000.00816.98
7.4.160.0090.00616.83
7.4.150.0090.01517.40
7.4.140.0120.00717.86
7.4.130.0090.00916.73
7.4.120.0070.01016.64
7.4.110.0120.01216.93
7.4.100.0100.01016.91
7.4.90.0070.01116.62
7.4.80.0080.01219.39
7.4.70.0100.01016.63
7.4.60.0130.01016.70
7.4.50.0040.00416.55
7.4.40.0070.00722.77
7.4.30.0180.00416.80
7.4.00.0070.00715.28
7.3.330.0000.00513.34
7.3.320.0060.00013.41
7.3.310.0030.00316.31
7.3.300.0030.00316.34
7.3.290.0100.00316.52
7.3.280.0060.01316.43
7.3.270.0060.01017.40
7.3.260.0080.01616.53
7.3.250.0050.01216.47
7.3.240.0150.00616.77
7.3.230.0150.00316.66
7.3.210.0070.01016.78
7.3.200.0130.00719.39
7.3.190.0110.00716.81
7.3.180.0070.00716.82
7.3.170.0080.00816.53
7.3.160.0130.00316.73
7.3.120.0030.00615.06
7.2.330.0100.00716.68
7.2.320.0130.00616.88
7.2.310.0060.01316.89
7.2.300.0090.00816.85
7.2.290.0130.01016.92
7.2.00.0030.01019.71
7.1.100.0040.01118.66
7.1.70.0000.00817.10
7.1.60.0070.01719.82
7.1.50.0030.01317.11
7.1.00.0070.03022.32
7.0.200.0070.00416.56
7.0.140.0070.07022.12
7.0.70.4970.04319.88
7.0.60.0070.08019.97
7.0.50.0100.08717.84
7.0.40.0100.05020.12
7.0.30.0130.05320.21
7.0.20.0230.04020.16
7.0.10.0270.06020.21
7.0.00.0130.04320.11
5.6.280.0030.07320.91
5.6.210.0030.04720.50
5.6.200.0100.07718.21
5.6.190.0130.05020.49
5.6.180.0230.07020.52
5.6.170.0200.04720.43
5.6.160.0200.07320.70
5.6.150.0000.04318.15
5.6.140.0100.05018.24
5.6.130.0030.04318.17
5.6.120.0070.04721.11
5.6.110.0030.04020.96
5.6.100.0070.08321.10
5.6.90.0070.08321.00
5.6.80.0070.05720.50
5.6.70.0200.06320.37
5.5.350.0100.07720.32
5.5.340.0070.07717.99
5.5.330.0130.07020.18
5.5.320.0070.07720.30
5.5.310.0400.06720.18
5.5.300.0070.04318.03
5.5.290.0030.08317.91
5.5.280.0070.08720.87
5.5.270.0100.03720.89
5.5.260.0030.06720.75
5.5.250.0100.08020.61
5.5.240.0000.07320.12
5.4.450.0100.06319.55
5.4.440.0700.06319.33
5.4.430.0230.04319.70
5.4.420.0800.04719.54
5.4.410.0830.05319.50
5.4.400.0870.06719.26
5.4.390.0800.05019.06
5.4.380.0200.05318.76
5.4.370.0370.05318.73
5.4.360.0300.04018.49
5.4.350.0090.04112.00
5.4.340.0110.03912.00
5.4.320.0060.04112.48
5.4.310.0060.03812.48
5.4.300.0070.03512.48
5.4.290.0080.04212.48
5.4.280.0100.03612.38
5.4.270.0070.03912.38
5.4.260.0110.03712.38
5.4.250.0100.04718.89
5.4.240.0000.05719.04
5.4.230.0070.05718.99
5.4.220.0000.06018.78
5.4.210.0170.04718.78
5.4.200.0070.05318.64
5.4.190.0030.06718.79
5.4.180.0170.04018.78
5.4.170.0230.03718.77
5.4.160.0000.05718.96
5.4.150.0100.05718.86
5.4.140.0100.07716.42
5.4.130.0070.05316.37
5.4.120.0270.04716.30
5.4.110.0100.07316.43
5.4.100.0000.07016.46
5.4.90.0130.06316.38
5.4.80.0070.05016.59
5.4.70.0130.04716.34
5.4.60.0070.04716.47
5.4.50.0200.05016.30
5.4.40.0030.05016.63
5.4.30.0130.04716.38
5.4.20.0030.06016.41
5.4.10.0070.05016.38
5.4.00.0230.03716.04
5.3.290.0070.04512.80
5.3.280.0230.03714.66
5.3.270.0070.05314.58
5.3.260.0030.07314.82
5.3.250.0170.05014.58
5.3.240.0100.05014.68
5.3.230.0070.06014.72
5.3.220.0000.06714.46
5.3.210.0030.07314.46
5.3.200.0130.07014.66
5.3.190.0070.07714.56
5.3.180.0070.05014.52
5.3.170.0100.06714.73
5.3.160.0100.04714.73
5.3.150.0070.05314.73
5.3.140.0100.04714.45
5.3.130.0100.05314.55
5.3.120.0200.05314.53
5.3.110.0030.05714.62
5.3.100.0070.05314.03
5.3.90.0070.05014.00
5.3.80.0130.04313.91
5.3.70.0100.04713.98
5.3.60.0030.05314.06
5.3.50.0100.05013.91
5.3.40.0100.04714.03
5.3.30.0170.04013.89
5.3.20.0100.06013.76
5.3.10.0100.04313.86
5.3.00.0030.05313.85
5.2.170.0070.04011.21
5.2.160.0070.03711.22
5.2.150.0130.03311.22
5.2.140.0030.04311.31
5.2.130.0070.04011.13
5.2.120.0070.04011.27
5.2.110.0100.03711.32
5.2.100.0070.03711.18
5.2.90.0070.04011.18
5.2.80.0030.04311.30
5.2.70.0000.05010.98
5.2.60.0100.03711.13
5.2.50.0030.04310.85
5.2.40.0000.04711.09
5.2.30.0070.04310.96
5.2.20.0070.03710.94
5.2.10.0070.04010.84
5.2.00.0070.06010.78
5.1.60.0030.0509.98
5.1.50.0070.03310.23
5.1.40.0070.03010.21
5.1.30.0030.04310.41
5.1.20.0000.04310.43
5.1.10.0030.03310.05
5.1.00.0030.03710.15
5.0.50.0030.0308.79
5.0.40.0070.0238.51
5.0.30.0070.0578.29
5.0.20.0030.0338.26
5.0.10.0070.0378.10
5.0.00.0070.0438.36
4.4.90.0070.0175.89
4.4.80.0030.0205.86
4.4.70.0070.0275.84
4.4.60.0070.0275.93
4.4.50.0030.0235.79
4.4.40.0030.0475.78
4.4.30.0100.0235.79
4.4.20.0000.0235.83
4.4.10.0000.0235.85
4.4.00.0030.0305.89
4.3.110.0000.0235.72
4.3.100.0030.0205.71
4.3.90.0030.0205.82
4.3.80.0030.0475.72
4.3.70.0030.0305.81
4.3.60.0070.0235.82
4.3.50.0000.0235.77
4.3.40.0000.0475.71
4.3.30.0030.0305.64
4.3.20.0000.0235.64
4.3.10.0000.0205.64
4.3.00.0030.0237.22

preferences:
45.55 ms | 401 KiB | 5 Q