3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate_string( $mathString ) { $mathString = trim($mathString); // trim white spaces $mathString = preg_replace('#[^0-9\+\-\*\/\(\) ]#', '', $mathString); // remove any non-numbers chars; exception for math operators var_dump($mathString); $compute = create_function("", "return (" . $mathString . ");" ); return 0 + $compute(); } $string = " 4141.58-3878.96-262.62"; echo calculate_string($string); // outputs 8

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.70.0070.00718.31
8.3.60.0180.00018.55
8.3.50.0050.01021.21
8.3.40.0090.00618.91
8.3.30.0140.00018.96
8.3.20.0020.00520.16
8.3.10.0080.00021.75
8.3.00.0000.00817.80
8.2.180.0100.01018.88
8.2.170.0070.00722.96
8.2.160.0070.00720.35
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00817.75
8.2.110.0060.00320.53
8.2.100.0060.00617.84
8.2.90.0000.00917.75
8.2.80.0000.00819.09
8.2.70.0040.00417.92
8.2.60.0040.00417.80
8.2.50.0000.00818.10
8.2.40.0030.00620.50
8.2.30.0070.00021.30
8.2.20.0050.00317.89
8.2.10.0040.00418.13
8.2.00.0040.00418.08
8.1.280.0110.00425.92
8.1.270.0090.00622.16
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00622.14
8.1.230.0060.00620.34
8.1.220.0080.00017.74
8.1.210.0050.00518.77
8.1.200.0060.00317.35
8.1.190.0090.00017.47
8.1.180.0040.00418.10
8.1.170.0000.00818.65
8.1.160.0000.00721.98
8.1.150.0070.00018.80
8.1.140.0000.00817.54
8.1.130.0030.00617.62
8.1.120.0030.00517.46
8.1.110.0050.00217.54
8.1.100.0000.00817.45
8.1.90.0070.00017.57
8.1.80.0000.00817.46
8.1.70.0000.00717.54
8.1.60.0000.00817.71
8.1.50.0060.00317.64
8.1.40.0000.00917.63
8.1.30.0040.00417.82
8.1.20.0040.00417.83
8.1.10.0040.00417.73
8.1.00.0000.00817.59
8.0.300.0000.00719.76
8.0.290.0000.00916.88
8.0.280.0000.00718.40
8.0.270.0070.00017.12
8.0.260.0050.00217.17
8.0.250.0070.00017.12
8.0.240.0000.00817.10
8.0.230.0000.00717.11
8.0.220.0070.00017.04
8.0.210.0000.00817.04
8.0.200.0030.00317.14
8.0.190.0030.00917.10
8.0.180.0050.00516.97
8.0.170.0000.00817.09
8.0.160.0030.00316.97
8.0.150.0030.00316.87
8.0.140.0000.00716.98
8.0.130.0030.00313.42
8.0.120.0040.00417.02
8.0.110.0040.00416.97
8.0.100.0080.00017.11
8.0.90.0040.00417.15
8.0.80.0040.01117.00
8.0.70.0040.00417.05
8.0.60.0030.00616.90
8.0.50.0040.00417.01
8.0.30.0120.00517.08
8.0.20.0150.00717.42
8.0.10.0040.00417.11
8.0.00.0100.01316.80
7.4.330.0000.00515.08
7.4.320.0000.00716.61
7.4.300.0000.00616.79
7.4.290.0070.00016.86
7.4.280.0030.00616.86
7.4.270.0040.00416.86
7.4.260.0030.00316.78
7.4.250.0000.00716.70
7.4.240.0000.00716.68
7.4.230.0000.00716.70
7.4.220.0060.01616.77
7.4.210.0070.00716.86
7.4.200.0030.00316.72
7.4.160.0000.01516.70
7.4.150.0090.00917.40
7.4.140.0080.01217.86
7.4.130.0090.01216.93
7.4.120.0090.01116.77
7.4.110.0120.01216.75
7.4.100.0100.01416.71
7.4.90.0070.01016.63
7.4.80.0090.01019.39
7.4.70.0130.00316.67
7.4.60.0100.00616.91
7.4.50.0060.00316.55
7.4.40.0030.01416.68
7.4.30.0100.00716.67
7.4.00.0030.01315.27
7.3.330.0050.00013.52
7.3.320.0000.00513.25
7.3.310.0070.00016.51
7.3.300.0030.00316.39
7.3.290.0080.00716.47
7.3.280.0090.01016.49
7.3.270.0180.00317.40
7.3.260.0120.00616.55
7.3.250.0090.00916.57
7.3.240.0180.00616.63
7.3.230.0120.00316.49
7.3.210.0090.00916.66
7.3.200.0030.01816.89
7.3.190.0080.00816.59
7.3.180.0130.00316.53
7.3.170.0070.01416.76
7.3.160.0080.00816.70
7.3.120.0100.00717.15
7.3.110.0130.00317.15
7.3.100.0030.01117.15
7.3.90.0080.00817.15
7.3.80.0030.01217.15
7.3.70.0040.01217.15
7.3.60.0060.00917.15
7.3.50.0140.00317.15
7.3.40.0060.01017.15
7.3.30.0070.00717.15
7.3.20.0040.00817.15
7.3.10.0090.00617.15
7.3.00.0070.00717.15
7.2.330.0110.00816.81
7.2.320.0160.00716.61
7.2.310.0060.01116.70
7.2.300.0090.01216.73
7.2.290.0060.00416.93
7.2.240.0070.01117.15
7.2.230.0100.00717.15
7.2.220.0070.01017.15
7.2.210.0000.01817.15
7.2.200.0030.01317.15
7.2.190.0000.01517.15
7.2.180.0000.01117.15
7.2.170.0000.01817.15
7.2.160.0080.00417.15
7.2.150.0070.01117.15
7.2.140.0000.01817.15
7.2.130.0090.00617.18
7.2.120.0140.00317.15
7.2.110.0030.01417.15
7.2.100.0040.01217.15
7.2.90.0030.01317.20
7.2.80.0030.00717.15
7.2.70.0110.00717.15
7.2.60.0100.00517.09
7.2.50.0070.00717.15
7.2.40.0070.01017.15
7.2.30.0090.00617.17
7.2.20.0110.00617.21
7.2.10.0040.01217.15
7.2.00.0030.01018.45
7.1.330.0070.01017.15
7.1.320.0090.00617.15
7.1.310.0120.00317.15
7.1.300.0100.00717.15
7.1.290.0030.00917.15
7.1.280.0080.00817.15
7.1.270.0040.01217.15
7.1.260.0060.01217.15
7.1.250.0040.01217.15
7.1.200.0060.00315.82
7.1.100.0030.00917.86
7.1.70.0000.00817.50
7.1.60.0070.00719.27
7.1.50.0070.01317.10
7.1.00.0030.07722.32
7.0.200.0000.00816.86
7.0.60.0130.07019.92
7.0.50.0070.03717.99
7.0.40.0170.08020.07
7.0.30.0200.04720.28
7.0.20.0230.07720.31
7.0.10.0130.04020.26
7.0.00.0070.08720.32
5.6.280.0000.03321.12
5.6.210.0100.04320.47
5.6.200.0100.06318.20
5.6.190.0030.08720.47
5.6.180.0230.06320.50
5.6.170.0370.04320.50
5.6.160.0030.05720.48
5.6.150.0030.08018.28
5.6.140.0130.06718.21
5.6.130.0100.08318.28
5.6.120.0070.05321.12
5.6.110.0170.07320.98
5.6.100.0030.05321.14
5.6.90.0130.06020.98
5.6.80.0030.03720.52
5.6.70.4600.04020.46
5.5.350.0170.04020.34
5.5.340.0030.05018.00
5.5.330.0070.06320.40
5.5.320.0200.04720.42
5.5.310.0230.05320.19
5.5.300.0000.08717.95
5.5.290.0000.04717.98
5.5.280.0030.05320.90
5.5.270.0130.07720.86
5.5.260.0070.06020.63
5.5.250.0300.06320.71
5.5.240.0300.06720.28
5.4.450.0270.06319.64
5.4.440.0370.06019.61
5.4.430.0230.05319.18
5.4.420.0300.05019.46
5.4.410.0170.06719.45
5.4.400.0400.05719.21
5.4.390.0300.06719.06
5.4.380.0270.07018.83
5.4.370.0230.06019.25
5.4.360.0270.07319.25
5.4.350.0270.06719.28
5.4.340.0270.07019.29
5.4.320.0330.06719.14
5.4.310.0230.06019.12
5.4.300.0170.06319.25
5.4.290.0330.06319.28
5.4.280.0170.07719.21
5.4.270.0300.06319.30
5.4.260.0270.07019.14
5.4.250.0300.05318.99
5.4.240.0270.07019.30
5.4.230.0330.06719.14
5.4.220.0330.06319.28
5.4.210.0170.08018.97
5.4.200.0230.06719.05
5.4.190.0330.06019.13
5.4.180.0300.06019.35
5.4.170.0170.07319.01
5.4.160.0270.06719.24
5.4.150.0270.05719.25
5.4.140.0300.06316.61
5.4.130.0430.04316.38
5.4.120.0230.06316.45
5.4.110.0300.06016.57
5.4.100.0170.07016.48
5.4.90.0230.05016.58
5.4.80.0200.05016.66
5.4.70.0030.07316.48
5.4.60.0000.05016.34
5.4.50.0000.04016.54
5.4.40.0230.03316.33
5.4.30.0270.06716.16
5.4.20.0170.04016.37

preferences:
54.85 ms | 401 KiB | 5 Q