3v4l.org

run code in 300+ PHP versions simultaneously
<?php $digits = 10; foreach([7887.0000000000000000, 8667887.0000000000000000, 0.0786451, 1.0786451] as $lastPrice) { $price = number_format($lastPrice, 16, '.', ''); $price = ltrim($price, '-'); $price = rtrim($price, '0'); list($d, $s) = explode('.', $price); var_dump($price); var_dump([$d, $s]); if ($d !== '0') { $round = $digits - strlen($d); } else { $round = $digits + strlen($s) - strlen(ltrim($s, '0')); } var_dump($round); } return; foreach ([7887.0000000000000000, 0.0786451] as $price) { $maxDigits = 5; $log = floor(round(log($price) / M_LN10, 10)); var_dump($log); var_dump((10 ** ($maxDigits - $log))); }

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.0180.00018.43
8.3.50.0060.00818.20
8.3.40.0150.00018.79
8.3.30.0110.00418.70
8.3.20.0000.00819.10
8.3.10.0040.00419.18
8.3.00.0000.00918.04
8.2.180.0070.01316.50
8.2.170.0070.00722.96
8.2.160.0180.00319.27
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0100.00026.16
8.2.120.0040.00420.98
8.2.110.0060.00320.42
8.2.100.0080.00419.76
8.2.90.0000.00817.63
8.2.80.0040.00419.03
8.2.70.0080.00018.05
8.2.60.0040.00418.16
8.2.50.0000.00818.10
8.2.40.0000.00821.14
8.2.30.0070.00019.60
8.2.20.0000.00718.17
8.2.10.0040.00418.13
8.2.00.0000.00821.26
8.1.280.0110.00725.92
8.1.270.0040.00423.75
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0100.00021.88
8.1.230.0070.00620.93
8.1.220.0060.00318.54
8.1.210.0000.00818.77
8.1.200.0040.00417.22
8.1.190.0040.00717.23
8.1.180.0030.00518.10
8.1.170.0000.00818.67
8.1.160.0040.00418.87
8.1.150.0020.00519.01
8.1.140.0070.00017.65
8.1.130.0000.00719.13
8.1.120.0040.00417.43
8.1.110.0000.00817.53
8.1.100.0000.00717.48
8.1.90.0050.00317.38
8.1.80.0040.00417.52
8.1.70.0070.00017.53
8.1.60.0040.00417.51
8.1.50.0000.00817.65
8.1.40.0000.00817.60
8.1.30.0060.00317.71
8.1.20.0000.00817.70
8.1.10.0040.00417.50
8.1.00.0040.00417.55
8.0.300.0050.00318.77
8.0.290.0070.00416.73
8.0.280.0030.00318.63
8.0.270.0030.00317.25
8.0.260.0000.00617.25
8.0.250.0040.00417.04
8.0.240.0000.00716.90
8.0.230.0000.00816.92
8.0.220.0070.00016.96
8.0.210.0000.00916.93
8.0.200.0030.00316.91
8.0.190.0030.00516.93
8.0.180.0040.00417.04
8.0.170.0040.00416.96
8.0.160.0040.00416.93
8.0.150.0000.00716.79
8.0.140.0000.01116.95
8.0.130.0000.00513.38
8.0.120.0050.00316.95
8.0.110.0000.00716.90
8.0.100.0000.00916.98
8.0.90.0000.00817.01
8.0.80.0140.00516.94
8.0.70.0000.00716.86
8.0.60.0050.00216.91
8.0.50.0040.00416.92
8.0.30.0090.00917.04
8.0.20.0080.01317.40
8.0.10.0040.00416.96
8.0.00.0100.01216.89
7.4.330.0000.00615.55
7.4.320.0000.00616.51
7.4.300.0030.00316.58
7.4.290.0030.00316.56
7.4.280.0000.00716.47
7.4.270.0030.00316.57
7.4.260.0000.00716.45
7.4.250.0000.00716.63
7.4.240.0040.00416.72
7.4.230.0070.00016.74
7.4.220.0030.00516.41
7.4.210.0100.00616.49
7.4.200.0030.00316.42
7.4.160.0060.01016.48
7.4.140.0100.01017.86
7.4.130.0170.00016.72
7.4.120.0110.00816.49
7.4.110.0140.00816.45
7.4.100.0030.01316.48
7.4.90.0160.00616.59
7.4.80.0120.01119.39
7.4.70.0100.00816.29
7.4.60.0070.01016.63
7.4.50.0140.00316.39
7.4.40.0060.01116.60
7.4.00.0070.00715.17
7.3.330.0000.00513.30
7.3.320.0000.00613.24
7.3.310.0000.00716.43
7.3.300.0000.00716.34
7.3.290.0070.00016.39
7.3.280.0150.00616.38
7.3.260.0110.00916.62
7.3.240.0090.01016.60
7.3.230.0070.01116.28
7.3.210.0050.01816.74
7.3.200.0060.01216.75
7.3.190.0100.00716.29
7.3.180.0110.00716.61
7.3.170.0140.00316.59
7.3.160.0050.01116.45
7.3.120.0070.01114.46
7.3.110.0000.01414.80
7.3.100.0040.01214.69
7.3.90.0070.00714.76
7.3.80.0070.01114.88
7.3.70.0100.00614.91
7.3.60.0090.00314.70
7.3.50.0000.00914.85
7.3.40.0090.00914.73
7.3.30.0090.00314.89
7.3.20.0060.00716.84
7.3.10.0080.00416.59
7.3.00.0030.00616.55
7.2.330.0130.00916.94
7.2.320.0090.00916.74
7.2.310.0120.00616.82
7.2.300.0110.00616.56
7.2.290.0130.00616.95
7.2.250.0000.01715.23
7.2.240.0070.01415.15
7.2.230.0060.00915.14
7.2.220.0030.01015.00
7.2.210.0080.00415.00
7.2.200.0120.00314.81
7.2.190.0060.00914.99
7.2.180.0030.00614.88
7.2.170.0090.00414.98
7.2.60.9240.00915.02
7.2.51.0280.01014.80
7.2.40.9180.01115.35
7.2.30.9430.01115.29
7.2.20.9690.01015.17
7.2.10.6070.01015.20
7.2.00.7280.01315.35
7.1.330.0100.00315.71
7.1.320.0090.00615.85
7.1.310.0070.00315.73
7.1.300.0030.01315.92
7.1.290.0060.00315.47
7.1.280.0000.01615.84
7.1.270.0070.00715.61
7.1.260.0080.00415.54
7.1.200.0030.00715.63
7.1.170.7810.01013.77
7.1.160.9710.01116.91
7.1.150.9030.01316.77
7.1.140.9930.01616.82
7.1.130.6280.01116.97
7.1.120.7370.01316.59
7.1.110.8780.01116.14
7.1.100.9060.01016.10
7.1.90.8950.01315.88
7.1.80.9020.01116.07
7.1.70.9520.00915.39
7.1.60.8950.01833.20
7.1.50.9890.01933.03
7.1.40.8760.01532.55
7.1.31.0840.01132.57
7.1.21.0340.01332.79
7.1.11.1030.01214.84
7.1.00.8070.01114.92

preferences:
31.06 ms | 401 KiB | 5 Q