3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MoneyHelper { public function getAmount($money) { $cleanString = preg_replace('/[^\d.,-]/', '', $money); $onlyNumbersString = preg_replace('/[^\d-]/', '', $money); $separatorsCountToBeErased = strlen($cleanString) - strlen($onlyNumbersString) - 1; $stringWithCommaOrDot = preg_replace('/[,.]/', '', $cleanString, $separatorsCountToBeErased); $removedThousandSeparator = preg_replace('/[.,](?=\d{3,}$)/', '', $stringWithCommaOrDot); //return (float) str_replace(',', '.', $removedThousandSeparator); return [ 'cleanString' => $cleanString, 'onlyNumbersString' => $onlyNumbersString, 'separatorsCountToBeErased' => $separatorsCountToBeErased, 'stringWithCommaOrDot' => $stringWithCommaOrDot, 'removedThousandSeparator' => $removedThousandSeparator, 'result' => (float) str_replace(',', '.', $removedThousandSeparator) ]; } } $obj = new MoneyHelper; echo var_dump($obj->getAmount('-200.000,54')) ;

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.0170.00716.88
8.3.60.0090.00618.56
8.3.50.0000.01518.61
8.3.40.0160.00318.92
8.3.30.0070.00718.93
8.3.20.0000.00821.73
8.3.10.0040.00423.61
8.3.00.0000.00823.70
8.2.190.0070.01417.00
8.2.180.0130.00925.92
8.2.170.0090.00619.07
8.2.160.0070.01322.96
8.2.150.0080.00025.66
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0090.00019.75
8.2.110.0060.00320.28
8.2.100.0070.00418.03
8.2.90.0050.00318.16
8.2.80.0040.00417.97
8.2.70.0000.00817.93
8.2.60.0030.00618.16
8.2.50.0040.00418.10
8.2.40.0080.00019.47
8.2.30.0040.00419.51
8.2.20.0000.00818.18
8.2.10.0080.00019.25
8.2.00.0040.00419.49
8.1.280.0130.01025.92
8.1.270.0040.00418.95
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0090.00317.50
8.1.230.0070.00422.59
8.1.220.0030.00617.79
8.1.210.0050.00318.84
8.1.200.0070.00317.47
8.1.190.0000.00917.35
8.1.180.0040.00418.10
8.1.170.0040.00418.65
8.1.160.0000.00718.82
8.1.150.0050.00218.83
8.1.140.0000.00722.07
8.1.130.0070.00020.09
8.1.120.0070.00017.48
8.1.110.0040.00417.52
8.1.100.0040.00417.46
8.1.90.0050.00317.49
8.1.80.0000.00917.46
8.1.70.0050.00317.59
8.1.60.0060.00317.61
8.1.50.0060.00317.70
8.1.40.0050.00317.68
8.1.30.0030.00717.69
8.1.20.0040.00417.73
8.1.10.0030.00517.69
8.1.00.0000.00717.61
8.0.300.0040.00419.85
8.0.290.0130.00216.58
8.0.280.0030.00318.38
8.0.270.0030.00317.19
8.0.260.0030.00318.38
8.0.250.0000.00717.09
8.0.240.0000.00817.05
8.0.230.0000.00717.02
8.0.220.0070.00017.05
8.0.210.0030.00516.90
8.0.200.0000.00617.06
8.0.190.0000.00717.06
8.0.180.0000.00817.02
8.0.170.0060.00317.04
8.0.160.0030.00616.88
8.0.150.0000.00716.89
8.0.140.0030.00616.98
8.0.130.0030.00313.43
8.0.120.0080.00016.98
8.0.110.0040.00416.83
8.0.100.0050.00316.81
8.0.90.0030.00517.09
8.0.80.0080.01017.02
8.0.70.0040.00417.07
8.0.60.0080.00016.93
8.0.50.0000.00717.06
8.0.30.0080.01017.34
8.0.20.0130.00617.46
8.0.10.0090.01417.31
8.0.00.0110.00916.99
7.4.330.0000.00516.86
7.4.320.0000.00616.79
7.4.300.0070.00016.68
7.4.290.0020.00516.82
7.4.280.0040.00416.75
7.4.270.0070.00016.84
7.4.260.0000.00716.73
7.4.250.0030.00516.65
7.4.240.0040.00416.92
7.4.230.0030.00316.86
7.4.220.0050.00316.85
7.4.210.0070.00916.85
7.4.200.0000.00716.66
7.4.160.0110.00616.68
7.4.150.0040.01316.62
7.4.140.0110.00717.65
7.4.130.0130.00616.67
7.4.120.0090.01016.57
7.4.110.0100.01116.74
7.4.100.0120.01216.79
7.4.90.0090.01216.75
7.4.80.0110.01118.09
7.4.70.0080.01016.81
7.4.60.0110.01016.80
7.4.50.0070.00816.62
7.4.40.0070.01116.66
7.4.30.0110.00816.66
7.4.20.0110.00916.76
7.4.10.0100.00716.52
7.4.00.0080.01016.03
7.3.330.0000.00513.29
7.3.320.0000.00513.36
7.3.310.0060.00316.37
7.3.300.0040.00416.51
7.3.290.0030.00316.56
7.3.280.0060.01316.43
7.3.270.0140.00416.50
7.3.260.0080.00916.58
7.3.250.0100.00716.39
7.3.240.0110.00616.60
7.3.230.0090.01316.60
7.3.220.0160.00316.55
7.3.210.0120.00916.56
7.3.200.0080.00916.56
7.3.190.0110.00816.69
7.3.180.0160.00516.53
7.3.170.0120.01116.80
7.3.160.0070.01316.56
7.3.150.0190.00316.88
7.3.140.0220.00316.48
7.3.130.0160.01016.72
7.3.120.0040.01515.72
7.3.110.0100.00815.72
7.3.100.0090.00715.80
7.3.90.0060.01015.78
7.3.80.0120.00315.77
7.3.70.0080.00515.85
7.3.60.0100.00515.85
7.3.50.0060.01115.85
7.3.40.0110.01015.73
7.3.30.0080.01115.86
7.3.20.0070.00716.74
7.3.10.0300.00616.70
7.3.00.0160.00616.07
7.2.340.0260.00916.78
7.2.330.0230.00616.82
7.2.320.0180.00516.73
7.2.310.0150.00916.78
7.2.300.0060.01116.77
7.2.290.0210.00616.76
7.2.280.0500.00516.73
7.2.270.0290.00616.81
7.2.260.0300.00416.68
7.2.250.0210.01116.80
7.2.240.0170.00915.89
7.2.230.0170.00616.17
7.2.220.0110.01116.09
7.2.210.0150.00815.98
7.2.200.0200.00615.91
7.2.190.0160.00915.90
7.2.180.0150.01016.02
7.2.170.0060.01616.03
7.2.160.0090.01415.99
7.2.150.0140.01016.96
7.2.140.0180.00616.95
7.2.130.0230.00916.49
7.2.120.0260.00516.24
7.2.110.0240.00816.29
7.2.100.0200.00516.40
7.2.90.0190.00516.33
7.2.80.0170.00916.50
7.2.70.0250.00416.28
7.2.60.0230.00416.41
7.2.50.0200.00716.38
7.2.40.0240.00816.44
7.2.30.0580.00816.23
7.2.20.0200.00816.43
7.2.10.0240.00716.27
7.2.00.0160.01016.36
7.1.330.0120.01315.99
7.1.320.0140.00916.02
7.1.310.0210.00215.89
7.1.300.0130.01016.08
7.1.290.0130.01115.69
7.1.280.0140.01015.99
7.1.270.0170.00815.79
7.1.260.0130.01015.84
7.1.250.0240.00615.37
7.1.240.0210.01015.90
7.1.230.0270.01015.91
7.1.220.0300.00015.90
7.1.210.0200.01015.81
7.1.200.0240.00715.70
7.1.190.0250.01415.71
7.1.180.0180.01415.84
7.1.170.0250.00815.96
7.1.160.0250.00615.90
7.1.150.0220.01115.87
7.1.140.0230.01415.86
7.1.130.0250.00615.86
7.1.120.0220.01315.74
7.1.110.0270.01615.68
7.1.100.0380.00715.86
7.1.90.0230.01115.81
7.1.80.0230.01215.66
7.1.70.0290.01115.84
7.1.60.0220.01315.87
7.1.50.0260.00915.96
7.1.40.0250.00515.85
7.1.30.0170.01415.76
7.1.20.0230.00815.82
7.1.10.0240.00615.98
7.1.00.0240.00615.68
7.0.330.0300.00514.67
7.0.320.0220.00715.43
7.0.310.0230.00715.60
7.0.300.0150.01515.50
7.0.290.0200.01315.54
7.0.280.0120.01815.58
7.0.270.0250.00915.57
7.0.260.0200.01315.54
7.0.250.0490.01515.68
7.0.240.0200.01015.54
7.0.230.0270.00415.39
7.0.220.0230.01215.51
7.0.210.0290.01115.53
7.0.200.0260.01115.64
7.0.190.0260.00415.65
7.0.180.0220.00615.53
7.0.170.0180.01115.43
7.0.160.0230.00915.56
7.0.150.0190.01115.59
7.0.140.0310.01215.42
7.0.130.0270.00415.64
7.0.120.0280.01115.58
7.0.110.0410.00815.55
7.0.100.0250.00715.41
7.0.90.0270.00515.49
7.0.80.0250.00615.44
7.0.70.0190.00915.57
7.0.60.0170.01315.38
7.0.50.0270.01115.47
7.0.40.0250.00615.41
7.0.30.0140.01415.55
7.0.20.0210.01115.41
7.0.10.0270.00715.47
7.0.00.0290.00715.34
5.6.400.0160.01615.70
5.6.390.0170.01316.08
5.6.380.0140.00915.42
5.6.370.0180.01515.76
5.6.360.0260.00915.96
5.6.350.0250.01016.03
5.6.340.0260.00915.70
5.6.330.0290.00416.09
5.6.320.0190.01515.93
5.6.310.0190.01516.23
5.6.300.0230.00916.05
5.6.290.0360.01116.15
5.6.280.0270.01216.23
5.6.270.0240.01216.01
5.6.260.0240.00715.78
5.6.250.0220.01215.98
5.6.240.0180.01815.96
5.6.230.0120.01916.13
5.6.220.0200.01216.03
5.6.210.0320.00815.97
5.6.200.0260.00816.10
5.6.190.0170.01715.91
5.6.180.0170.01516.02
5.6.170.0280.00516.09
5.6.160.0280.00315.97
5.6.150.0160.01515.82
5.6.140.0190.01416.00
5.6.130.0170.01516.18
5.6.120.0260.00616.00
5.6.110.0280.01116.22
5.6.100.0260.00616.00
5.6.90.0220.00916.27
5.6.80.0100.02015.98
5.6.70.0240.01015.83
5.6.60.0220.00916.06
5.6.50.0140.01915.98
5.6.40.0150.01515.81
5.6.30.0320.00315.83
5.6.20.0200.01415.86
5.6.10.0260.00916.10
5.6.00.0250.00915.90

preferences:
47.63 ms | 401 KiB | 5 Q