3v4l.org

run code in 300+ PHP versions simultaneously
<?php $n = '1,512,523.00'; function parseFloat($ptString) { if (strlen($ptString) == 0) { return false; } $pString = str_replace(" ", "", $ptString); if (substr_count($pString, ",") > 1) $pString = str_replace(",", "", $pString); if (substr_count($pString, ".") > 1) $pString = str_replace(".", "", $pString); $pregResult = array(); $commaset = strpos($pString,','); if ($commaset === false) {$commaset = -1;} $pointset = strpos($pString,'.'); if ($pointset === false) {$pointset = -1;} $pregResultA = array(); $pregResultB = array(); if ($pointset < $commaset) { preg_match('#(([-]?[0-9]+(\.[0-9])?)+(,[0-9]+)?)#', $pString, $pregResultA); } preg_match('#(([-]?[0-9]+(,[0-9])?)+(\.[0-9]+)?)#', $pString, $pregResultB); if ((isset($pregResultA[0]) && (!isset($pregResultB[0]) || @strstr($preResultA[0],$pregResultB[0]) == 0 || !$pointset))) { $numberString = $pregResultA[0]; $numberString = str_replace('.','',$numberString); $numberString = str_replace(',','.',$numberString); } elseif (isset($pregResultB[0]) && (!isset($pregResultA[0]) || @strstr($pregResultB[0],$preResultA[0]) == 0 || !$commaset)) { $numberString = $pregResultB[0]; $numberString = str_replace(',','',$numberString); } else { return false; } $result = (float)$numberString; return $result; } echo parseFloat($n);

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.0120.00316.63
8.3.60.0120.00818.56
8.3.50.0110.00821.33
8.3.40.0130.00719.01
8.3.30.0030.01020.34
8.3.20.0040.00420.14
8.3.10.0000.00821.09
8.3.00.0080.00022.48
8.2.180.0070.00718.52
8.2.170.0140.00719.04
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00320.86
8.2.110.0030.00719.23
8.2.100.0110.00018.03
8.2.90.0030.00519.40
8.2.80.0060.00318.02
8.2.70.0040.00417.63
8.2.60.0080.00018.05
8.2.50.0000.00818.07
8.2.40.0080.00018.21
8.2.30.0020.00519.48
8.2.20.0080.00017.78
8.2.10.0040.00417.80
8.2.00.0080.00017.87
8.1.280.0100.00325.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.96
8.1.230.0040.00721.05
8.1.220.0000.01018.77
8.1.210.0030.00618.97
8.1.200.0040.00417.48
8.1.190.0000.00817.52
8.1.180.0080.00018.10
8.1.170.0080.00318.75
8.1.160.0040.00418.95
8.1.150.0040.00418.83
8.1.140.0040.00417.73
8.1.130.0070.00017.92
8.1.120.0000.00717.65
8.1.110.0050.00217.60
8.1.100.0000.00817.64
8.1.90.0040.00417.54
8.1.80.0040.00417.54
8.1.70.0000.00717.66
8.1.60.0000.00917.80
8.1.50.0040.00417.60
8.1.40.0000.00817.61
8.1.30.0000.00717.82
8.1.20.0040.00417.75
8.1.10.0040.00417.70
8.1.00.0040.00417.62
8.0.300.0000.00720.01
8.0.290.0000.00717.30
8.0.280.0040.00418.42
8.0.270.0000.00717.23
8.0.260.0070.00017.06
8.0.250.0040.00417.02
8.0.240.0000.00817.16
8.0.230.0050.00217.14
8.0.220.0030.00417.12
8.0.210.0040.00416.96
8.0.200.0030.00317.12
8.0.190.0000.00717.08
8.0.180.0000.00817.15
8.0.170.0000.00717.08
8.0.160.0070.00017.13
8.0.150.0070.00017.05
8.0.140.0000.01016.92
8.0.130.0030.00313.43
8.0.120.0080.00017.04
8.0.110.0080.00017.02
8.0.100.0000.00817.05
8.0.90.0000.00716.96
8.0.80.0100.01317.12
8.0.70.0000.00817.05
8.0.60.0050.00216.90
8.0.50.0050.00217.11
8.0.30.0110.00717.30
8.0.20.0060.01317.40
8.0.10.0030.00517.24
8.0.00.0130.00817.08
7.4.330.0050.00016.81
7.4.320.0030.00316.85
7.4.300.0050.00316.84
7.4.290.0030.00316.85
7.4.280.0070.00016.73
7.4.270.0030.00316.83
7.4.260.0050.00013.42
7.4.250.0090.00016.71
7.4.240.0030.00316.83
7.4.230.0070.00016.72
7.4.220.0060.01216.62
7.4.210.0050.01116.76
7.4.200.0070.00016.66
7.4.190.0000.00716.63
7.4.160.0000.01616.82
7.4.150.0090.00917.40
7.4.140.0120.00617.86
7.4.130.0110.00616.77
7.4.120.0130.00516.75
7.4.110.0130.00316.78
7.4.100.0130.00316.75
7.4.90.0070.01016.73
7.4.80.0090.00919.39
7.4.70.0060.01216.57
7.4.60.0080.00816.67
7.4.50.0030.00316.92
7.4.40.0000.01122.77
7.4.30.0170.00616.78
7.4.00.0060.00914.87
7.3.330.0050.00013.49
7.3.320.0060.00013.52
7.3.310.0040.00416.54
7.3.300.0000.00716.48
7.3.290.0110.00416.54
7.3.280.0140.00416.56
7.3.270.0120.00617.40
7.3.260.0060.01718.24
7.3.250.0120.00716.58
7.3.240.0090.01316.55
7.3.230.0130.00616.50
7.3.210.0080.00816.45
7.3.200.0060.01319.39
7.3.190.0060.01516.57
7.3.180.0030.01316.81
7.3.170.0110.00816.76
7.3.160.0070.01016.71
7.3.120.0100.00714.99
7.2.330.0110.00717.01
7.2.320.0040.01416.86
7.2.310.0070.01417.04
7.2.300.0040.01916.92
7.2.290.0090.00917.00
7.2.00.0040.00819.86
7.1.200.0070.00715.94
7.1.100.0080.00318.46
7.1.70.0000.00717.14
7.1.60.0130.01319.17
7.1.50.0070.01417.23
7.1.00.0000.08322.42
7.0.200.0000.00716.68
7.0.140.0100.06722.15
7.0.100.0030.08320.00
7.0.90.0030.08320.06
7.0.80.0070.08020.05
7.0.70.0170.07319.96
7.0.60.0170.08020.09
7.0.50.0100.05720.42
7.0.40.0070.08020.15
7.0.30.0170.07020.04
7.0.20.0200.06020.11
7.0.10.0070.07020.13
7.0.00.0200.06720.12
5.6.280.0130.06721.04
5.6.250.0170.07020.77
5.6.240.0000.07320.78
5.6.230.0200.06720.77
5.6.220.0070.08020.61
5.6.210.0030.08720.54
5.6.200.0070.08721.19
5.6.190.0070.08021.07
5.6.180.0100.07721.05
5.6.170.0030.08321.07
5.6.160.0030.08021.14
5.6.150.0030.04721.16
5.6.140.0030.09321.12
5.6.130.0100.08320.95
5.6.120.0100.08321.08
5.6.110.0030.09021.03
5.6.100.0030.08321.18
5.6.90.0100.08321.10
5.6.80.0130.07320.44
5.6.70.0130.07020.45
5.6.60.0070.08020.43
5.6.50.0130.07020.43
5.6.40.0030.07720.41
5.6.30.0070.07020.38
5.6.20.0070.08020.41
5.6.10.0130.07020.39
5.6.00.0070.04020.47
5.5.380.0100.07320.38
5.5.370.0070.07720.56
5.5.360.0100.08020.52
5.5.350.0100.08020.41
5.5.340.0070.08320.95
5.5.330.0130.07320.82
5.5.320.0130.06320.93
5.5.310.0130.06320.85
5.5.300.0170.07720.75
5.5.290.0170.07720.87
5.5.280.0000.05720.79
5.5.270.0130.07720.90
5.5.260.0100.07020.77
5.5.250.0070.06320.75
5.5.240.0100.07320.30
5.5.230.0100.08020.22
5.5.220.0170.07320.20
5.5.210.0130.04320.32
5.5.200.0130.08020.28
5.5.190.0100.07720.24
5.5.180.0100.06320.10
5.5.160.0100.05320.20
5.5.150.0100.07720.25
5.5.140.0100.07320.07
5.5.130.0170.07020.25
5.5.120.0100.07320.25
5.5.110.0100.07020.00
5.5.100.0000.09020.09
5.5.90.0070.07020.11
5.5.80.0030.05720.18
5.5.70.0000.07320.18
5.5.60.0070.07320.11
5.5.50.0000.08320.13
5.5.40.0030.06320.16
5.5.30.0070.08020.13
5.5.20.0000.07020.04
5.5.10.0000.08320.09
5.5.00.0070.08320.14
5.4.450.0070.08019.37
5.4.440.0100.08019.47
5.4.430.0070.08019.45
5.4.420.0130.07319.22
5.4.410.0100.07019.33
5.4.400.0130.06719.05
5.4.390.0000.08019.18
5.4.380.0100.06718.85
5.4.370.0030.07319.04
5.4.360.0070.04719.04
5.4.350.0130.07718.86
5.4.340.0100.06719.24
5.4.320.0130.07718.95
5.4.310.0130.06719.03
5.4.300.0100.05719.13
5.4.290.0170.06019.13
5.4.280.0030.08019.04
5.4.270.0100.07319.16
5.4.260.0170.06019.09
5.4.250.0130.06718.85
5.4.240.0070.07718.90
5.4.230.0130.03719.16
5.4.220.0130.06719.00
5.4.210.0100.07319.04
5.4.200.0130.06719.02
5.4.190.0030.08019.17
5.4.180.0130.07319.02
5.4.170.0070.07719.14
5.4.160.0030.07019.14
5.4.150.0030.06318.88
5.4.140.0030.08016.49
5.4.130.0030.07316.30
5.4.120.0070.07016.54
5.4.110.0100.06316.54
5.4.100.0130.06716.45
5.4.90.0130.05016.49
5.4.80.0100.07016.41
5.4.70.0130.03716.27
5.4.60.0100.06716.30
5.4.50.0030.06716.47
5.4.40.0030.05016.50
5.4.30.0030.07316.48
5.4.20.0070.03016.46
5.4.10.0070.05716.46
5.4.00.0070.04015.88
5.3.290.0130.05314.67
5.3.280.0100.07714.66
5.3.270.0000.08014.70
5.3.260.0070.07714.58
5.3.250.0070.04014.76
5.3.240.0130.06714.61
5.3.230.0170.06314.71
5.3.220.0100.07014.65
5.3.210.0070.04714.61
5.3.200.0070.07314.47
5.3.190.0030.05314.65
5.3.180.0070.04714.64
5.3.170.0100.06714.68
5.3.160.0070.07014.68
5.3.150.0070.05714.62
5.3.140.0070.07314.50
5.3.130.0070.07314.60
5.3.120.0030.08014.63
5.3.110.0130.06714.66
5.3.100.0070.04314.09
5.3.90.0070.07714.05
5.3.80.0070.07014.11
5.3.70.0100.07014.05
5.3.60.0170.06314.13
5.3.50.0070.07014.00
5.3.40.0030.05313.95
5.3.30.0030.08013.99
5.3.20.0100.07013.73
5.3.10.0130.06013.70
5.3.00.0100.03713.60
5.2.170.0100.06011.50
5.2.160.0070.06311.50
5.2.150.0070.03311.50
5.2.140.0030.06711.50
5.2.130.0070.06311.50
5.2.120.0030.06011.50
5.2.110.0170.05011.50
5.2.100.0100.05011.50
5.2.90.0100.03711.50
5.2.80.0100.04711.50
5.2.70.0100.05311.50
5.2.60.0130.05711.50
5.2.50.0070.06011.50
5.2.40.0200.04711.50
5.2.30.0030.06011.50
5.2.20.0070.05011.50
5.2.10.0030.05311.50
5.2.00.0000.06311.50
5.1.60.0070.04711.50
5.1.50.0030.05311.50
5.1.40.0070.05311.50
5.1.30.0070.05011.50
5.1.20.0100.05011.50
5.1.10.0030.05711.50
5.1.00.0030.05711.50
5.0.50.0030.04711.50
5.0.40.0030.04311.50
5.0.30.0030.05011.50
5.0.20.0000.02011.50
5.0.10.0030.02011.50
5.0.00.0000.06711.50
4.4.90.0030.03311.50
4.4.80.0030.03311.50
4.4.70.0000.03711.50
4.4.60.0070.03011.50
4.4.50.0000.04011.50
4.4.40.0000.04011.50
4.4.30.0030.03311.50
4.4.20.0030.03711.50
4.4.10.0030.03011.50
4.4.00.0030.05711.50
4.3.110.0000.02311.50
4.3.100.0000.02011.50
4.3.90.0000.02011.50
4.3.80.0070.02011.50
4.3.70.0000.01711.50
4.3.60.0000.01711.50
4.3.50.0000.01711.50
4.3.40.0030.02011.50
4.3.30.0000.02011.50
4.3.20.0000.01711.50
4.3.10.0000.01711.50
4.3.00.0000.01311.50

preferences:
37.71 ms | 401 KiB | 5 Q