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); exit;

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.0140.00718.48
8.3.50.0120.00321.20
8.3.40.0090.00619.18
8.3.30.0140.00019.27
8.3.20.0050.00320.21
8.3.10.0040.00422.09
8.3.00.0090.00022.44
8.2.180.0070.01417.00
8.2.170.0130.01022.96
8.2.160.0090.00620.27
8.2.150.0000.00924.18
8.2.140.0000.01724.66
8.2.130.0140.00426.16
8.2.120.0040.00419.79
8.2.110.0090.00022.39
8.2.100.0120.00019.40
8.2.90.0030.00619.26
8.2.80.0040.00419.32
8.2.70.0040.00717.73
8.2.60.0040.00418.05
8.2.50.0030.00618.07
8.2.40.0070.00418.22
8.2.30.0000.00717.98
8.2.20.0040.00418.05
8.2.10.0000.00817.94
8.2.00.0090.00017.93
8.1.280.0080.00625.92
8.1.270.0060.00320.61
8.1.260.0000.00826.35
8.1.250.0000.00728.09
8.1.240.0030.00623.79
8.1.230.0090.00319.10
8.1.220.0080.00017.78
8.1.210.0000.00818.77
8.1.200.0060.00317.47
8.1.190.0030.00617.43
8.1.180.0000.00918.75
8.1.170.0000.00818.51
8.1.160.0000.00722.13
8.1.150.0000.00718.72
8.1.140.0000.00717.70
8.1.130.0100.00017.88
8.1.120.0000.00717.63
8.1.110.0060.00317.62
8.1.100.0000.00717.63
8.1.90.0070.00017.52
8.1.80.0040.00417.49
8.1.70.0000.00717.54
8.1.60.0080.00017.64
8.1.50.0030.00617.77
8.1.40.0060.00317.59
8.1.30.0040.00417.77
8.1.20.0040.00417.85
8.1.10.0050.00517.75
8.1.00.0000.00817.56
8.0.300.0030.00618.77
8.0.290.0050.00217.18
8.0.280.0030.00318.39
8.0.270.0000.00717.35
8.0.260.0060.00016.95
8.0.250.0080.00017.08
8.0.240.0060.00317.04
8.0.230.0050.00217.23
8.0.220.0030.00317.10
8.0.210.0000.00717.00
8.0.200.0080.00017.04
8.0.190.0030.00517.22
8.0.180.0070.00017.11
8.0.170.0040.00417.08
8.0.160.0040.00417.18
8.0.150.0040.00417.10
8.0.140.0080.00017.06
8.0.130.0000.00713.48
8.0.120.0040.00417.09
8.0.110.0050.00317.09
8.0.100.0030.00517.10
8.0.90.0030.00517.14
8.0.80.0090.00617.15
8.0.70.0050.00317.14
8.0.60.0040.00417.11
8.0.50.0030.00516.91
8.0.30.0080.01117.13
8.0.20.0100.00817.40
8.0.10.0070.00017.30
8.0.00.0120.00617.01
7.4.330.0070.00015.00
7.4.320.0060.00016.81
7.4.300.0030.00316.71
7.4.290.0000.00716.73
7.4.280.0040.00416.84
7.4.270.0070.00016.72
7.4.260.0040.00416.77
7.4.250.0000.00816.66
7.4.240.0030.00516.77
7.4.230.0070.00016.86
7.4.220.0120.01516.70
7.4.210.0080.00816.79
7.4.200.0000.00716.88
7.4.190.0040.00416.71
7.4.160.0070.01016.83
7.4.150.0070.01117.40
7.4.140.0080.01117.86
7.4.130.0100.00916.81
7.4.120.0130.00616.80
7.4.110.0100.00616.58
7.4.100.0120.01216.88
7.4.90.0120.00616.55
7.4.80.0040.01419.39
7.4.70.0070.01016.81
7.4.60.0100.00816.75
7.4.50.0040.00416.69
7.4.40.0100.00622.77
7.4.30.0080.00816.71
7.4.00.0110.00015.27
7.3.330.0000.00613.36
7.3.320.0050.00013.48
7.3.310.0030.00316.50
7.3.300.0070.00016.54
7.3.290.0100.01116.56
7.3.280.0140.00316.54
7.3.270.0090.01317.40
7.3.260.0120.00616.57
7.3.250.0100.01116.60
7.3.240.0030.01316.82
7.3.230.0110.00716.74
7.3.210.0130.00316.51
7.3.200.0040.01419.39
7.3.190.0170.00616.71
7.3.180.0130.00316.61
7.3.170.0040.01416.93
7.3.160.0000.01516.57
7.3.120.0060.00915.05
7.3.10.0080.00316.42
7.3.00.0040.00716.82
7.2.330.0100.00716.86
7.2.320.0150.00316.84
7.2.310.0130.00816.68
7.2.300.0030.01416.82
7.2.290.0030.01416.92
7.2.130.0090.00317.08
7.2.120.0060.00616.93
7.2.110.0080.00317.15
7.2.100.0090.00317.02
7.2.90.0000.01217.21
7.2.80.0040.01116.84
7.2.70.0060.00317.19
7.2.60.0090.00617.29
7.2.50.0080.00417.12
7.2.40.0050.00517.07
7.2.30.0060.00617.17
7.2.20.0060.00316.99
7.2.10.0060.00317.16
7.2.00.0080.00718.24
7.1.250.0090.00315.92
7.1.100.0080.00818.08
7.1.70.0000.00717.10
7.1.60.0100.01419.82
7.1.50.0060.01617.21
7.1.00.0070.03022.53
7.0.200.0000.00816.60
7.0.140.0070.07022.15
7.0.60.0070.05719.85
7.0.50.0030.08717.99
7.0.40.0170.07320.14
7.0.30.0130.06020.14
7.0.20.0370.06020.20
7.0.10.0130.07720.15
7.0.00.0130.04020.17
5.6.280.0130.06020.90
5.6.210.0170.07020.45
5.6.200.0100.07718.25
5.6.190.0100.07320.52
5.6.180.0370.07720.48
5.6.170.0230.07720.52
5.6.160.0030.08020.55
5.6.150.0070.04718.19
5.6.140.0130.07718.28
5.6.130.0100.07718.18
5.6.120.0170.05721.14
5.6.110.0170.08020.95
5.6.100.0170.05320.88
5.6.90.0100.08020.96
5.6.80.0170.07020.34
5.6.70.4330.03720.38
5.5.350.0130.08320.34
5.5.340.0070.05318.08
5.5.330.0000.04320.29
5.5.320.0300.03020.30
5.5.310.0300.06020.34
5.5.300.0100.05017.96
5.5.290.0070.04317.95
5.5.280.0100.03320.86
5.5.270.0030.04320.88
5.5.260.0130.04720.68
5.5.250.0070.07020.49
5.5.240.0230.08020.26
5.4.450.0630.06719.55
5.4.440.0170.06719.46
5.4.430.0030.06319.16
5.4.420.0270.06719.45
5.4.410.0130.06019.50
5.4.400.0400.06018.78
5.4.390.0530.06318.80
5.4.380.0230.07718.46
5.4.370.0170.06318.61
5.4.360.0170.04718.78
5.4.350.0070.03812.00
5.4.340.0050.04212.00
5.4.320.0040.03712.48
5.4.310.0050.03812.48
5.4.300.0080.03312.49
5.4.290.0040.03912.48
5.4.280.0070.03512.38
5.4.270.0050.03812.38
5.4.260.0050.04212.38
5.4.250.0100.04718.91
5.4.240.0100.05018.75
5.4.230.0000.06018.94
5.4.220.0000.06018.91
5.4.210.0130.04718.96
5.4.200.0170.04318.75
5.4.190.0070.05018.63
5.4.180.0070.05018.62
5.4.170.0000.05718.94
5.4.160.0200.05718.96
5.4.150.0070.05318.90
5.4.140.0070.05016.55
5.4.130.0070.04716.35
5.4.120.0070.05016.42
5.4.110.0100.04716.45
5.4.100.0100.04316.37
5.4.90.0070.04716.48
5.4.80.0130.06716.60
5.4.70.0070.05316.56
5.4.60.0070.04716.49
5.4.50.0070.05016.37
5.4.40.0070.06016.55
5.4.30.0070.04716.38
5.4.20.0200.03716.41
5.4.10.0030.06016.49
5.4.00.0030.05016.04
5.3.290.0080.04312.80
5.3.280.0130.04314.49
5.3.270.0030.05714.50
5.3.260.0130.04314.66
5.3.250.0130.04314.75
5.3.240.0100.04714.43
5.3.230.0000.05714.73
5.3.220.0130.04314.53
5.3.210.0000.06014.70
5.3.200.0100.04714.78
5.3.190.0100.05014.66
5.3.180.0100.04714.39
5.3.170.0070.05314.57
5.3.160.0000.06714.54
5.3.150.0070.05014.55
5.3.140.0100.05714.72
5.3.130.0100.05314.61
5.3.120.0130.04714.62
5.3.110.0100.05014.71
5.3.100.0100.04714.01
5.3.90.0130.04714.01
5.3.80.0130.05014.10
5.3.70.0130.06014.18
5.3.60.0030.05014.09
5.3.50.0100.04313.93
5.3.40.0170.06014.16
5.3.30.0070.06713.90
5.3.20.0030.05313.84
5.3.10.0100.04713.73
5.3.00.0030.05313.85
5.2.170.0030.04010.96
5.2.160.0100.03711.15
5.2.150.0100.05710.96
5.2.140.0070.04711.21
5.2.130.0000.04311.08
5.2.120.0030.04011.17
5.2.110.0070.04011.31
5.2.100.0070.04310.91
5.2.90.0070.03711.25
5.2.80.0000.04311.07
5.2.70.0030.04011.15
5.2.60.0030.04011.12
5.2.50.0030.04711.12
5.2.40.0070.04010.99
5.2.30.0000.04310.87
5.2.20.0030.04010.92
5.2.10.0030.04010.84
5.2.00.0070.03710.70
5.1.60.0070.0309.94
5.1.50.0070.03010.03
5.1.40.0070.0309.97
5.1.30.0170.03010.23
5.1.20.0030.04710.43
5.1.10.0030.03710.16
5.1.00.0130.02710.13
5.0.50.0130.0208.46
5.0.40.0070.0238.61
5.0.30.0100.0538.29
5.0.20.0000.0308.24
5.0.10.0030.0278.24
5.0.00.0000.0438.13
4.4.90.0070.0206.41
4.4.80.0030.0206.41
4.4.70.0000.0236.41
4.4.60.0100.0136.41
4.4.50.0000.0236.41
4.4.40.0000.0406.41
4.4.30.0030.0206.41
4.4.20.0030.0276.41
4.4.10.0030.0206.41
4.4.00.0030.0336.69
4.3.110.0030.0206.69
4.3.100.0070.0176.69
4.3.90.0000.0236.69
4.3.80.0030.0306.69
4.3.70.0100.0136.69
4.3.60.0000.0236.69
4.3.50.0070.0176.69
4.3.40.0030.0306.69
4.3.30.0000.0236.69
4.3.20.0000.0206.69
4.3.10.0000.0236.69
4.3.00.0030.0236.48

preferences:
52.08 ms | 400 KiB | 5 Q