3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decimal($check, $args) { $maxFractionalPlaces = isset($args[0]) ? $args[0] : 2; $maxIntegralPlaces = isset($args[1]) ? $args[1] : null; $allFractionalPlacesRequired = isset($args[2]) ? $args[2] : false; $seperator = t('common.decimalSeperator'); if ($seperator == 'common.decimalSeperator') { $seperator = '.'; } if ($seperator != '.') { $check = str_replace($seperator, '.', $check); } if (!is_numeric($check)) { return false; } if (!$allFractionalPlacesRequired) { $fractionalRegex = '\\.[0-9]{0,' . $maxFractionalPlaces . '}'; } else { $fractionalRegex = '\\.[0-9]{' . $maxFractionalPlaces . '}'; } if ($maxIntegralPlaces > 0) { $integralRegex = '[-+]?[0-9]{0,' . $maxIntegralPlaces . '}'; } else { $integralRegex = '[-+]?[0-9]*'; } $regex = '/^' . $integralRegex . $fractionalRegex . '$/'; if (!$allFractionalPlacesRequired) { if (preg_match('/^' . $integralRegex . '$/', $check) || preg_match($regex, $check)) { return true; } } else { if (preg_match($regex, $check)) { return true; } } return false; } var_dump(decimal(1.8867 ,array(4, 10)));

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.0070.01116.63
8.3.50.0140.00018.32
8.3.40.0040.01118.84
8.3.30.0150.00018.79
8.3.20.0040.00420.39
8.3.10.0080.00023.51
8.3.00.0000.00819.91
8.2.180.0030.01416.63
8.2.170.0110.00322.96
8.2.160.0070.01320.47
8.2.150.0050.00324.18
8.2.140.0070.00324.66
8.2.130.0000.00819.27
8.2.120.0050.00326.35
8.2.110.0030.00619.39
8.2.100.0040.00717.84
8.2.90.0030.00519.27
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0000.01117.80
8.2.50.0060.00318.07
8.2.40.0040.00418.16
8.2.30.0070.00018.01
8.2.20.0050.00217.76
8.2.10.0050.00318.02
8.2.00.0070.00018.08
8.1.280.0090.00925.92
8.1.270.0120.00622.02
8.1.260.0070.00028.09
8.1.250.0080.00028.09
8.1.240.0060.00322.62
8.1.230.0070.00719.07
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0100.00017.22
8.1.190.0080.00017.36
8.1.180.0040.00418.10
8.1.170.0030.00618.63
8.1.160.0070.00018.90
8.1.150.0040.00418.85
8.1.140.0030.00619.50
8.1.130.0070.00017.67
8.1.120.0000.00717.34
8.1.110.0050.00217.38
8.1.100.0040.00417.30
8.1.90.0000.00817.34
8.1.80.0030.00717.38
8.1.70.0070.00017.39
8.1.60.0000.00817.44
8.1.50.0030.00617.59
8.1.40.0030.00617.44
8.1.30.0000.00817.68
8.1.20.0050.00317.64
8.1.10.0040.00417.58
8.1.00.0070.00617.43
8.0.300.0090.00018.77
8.0.290.0050.00216.63
8.0.280.0000.00718.40
8.0.270.0030.00317.21
8.0.260.0000.00917.18
8.0.250.0000.00717.00
8.0.240.0000.00717.00
8.0.230.0030.00317.02
8.0.220.0070.00016.98
8.0.210.0040.00416.91
8.0.200.0000.00617.04
8.0.190.0050.00316.88
8.0.180.0070.00016.96
8.0.170.0040.00416.91
8.0.160.0050.00316.96
8.0.150.0040.00416.85
8.0.140.0050.00316.90
8.0.130.0000.00613.39
8.0.120.0030.00616.89
8.0.110.0050.00316.88
8.0.100.0000.00816.91
8.0.90.0000.00816.74
8.0.80.0070.01416.87
8.0.70.0050.00216.75
8.0.60.0080.00016.94
8.0.50.0040.00416.80
8.0.30.0110.00916.90
8.0.20.0060.01417.40
8.0.10.0040.00417.06
8.0.00.0090.01216.79
7.4.330.0000.00516.83
7.4.320.0030.00316.54
7.4.300.0030.00516.54
7.4.290.0030.00316.59
7.4.280.0050.00316.52
7.4.270.0040.00416.44
7.4.260.0030.00316.48
7.4.250.0070.00016.39
7.4.240.0000.00716.55
7.4.230.0070.00016.44
7.4.220.0110.00816.43
7.4.210.0060.01216.45
7.4.200.0000.00716.35
7.4.160.0040.01116.43
7.4.150.0180.00017.40
7.4.140.0120.01117.86
7.4.130.0110.00916.57
7.4.120.0110.00516.48
7.4.110.0100.00616.70
7.4.100.0120.00616.42
7.4.90.0030.01416.55
7.4.80.0100.00919.39
7.4.70.0090.00916.62
7.4.60.0080.00816.40
7.4.50.0070.00716.70
7.4.40.0080.00816.55
7.4.30.0140.00516.70
7.4.00.0060.00615.16
7.3.330.0040.00413.41
7.3.320.0030.00313.41
7.3.310.0030.00316.22
7.3.300.0060.00016.52
7.3.290.0050.01416.43
7.3.280.0050.01316.38
7.3.270.0070.01017.40
7.3.260.0120.00616.34
7.3.250.0100.00916.45
7.3.240.0120.00616.33
7.3.230.0150.00416.41
7.3.210.0090.00816.61
7.3.200.0070.01416.46
7.3.190.0150.00616.50
7.3.180.0030.01716.47
7.3.170.0130.00316.41
7.3.160.0130.00316.37
7.2.330.0070.01016.63
7.2.320.0150.00816.67
7.2.310.0090.01216.88
7.2.300.0060.01216.54
7.2.290.0070.01016.64
7.2.60.0090.00616.80
7.2.00.0060.00919.37
7.1.200.0030.00315.63
7.1.100.0030.01018.04
7.1.70.0040.00416.87
7.1.60.0110.01419.05
7.1.50.0090.00616.59
7.1.00.0000.08022.54
7.0.200.0050.00316.55
7.0.60.0130.06319.94
7.0.50.0170.05717.88
7.0.40.0100.08020.02
7.0.30.0300.06720.07
7.0.20.0400.06720.08
7.0.10.0030.08320.16
7.0.00.0030.08720.10
5.6.280.0000.05320.90
5.6.210.0100.07320.71
5.6.200.0030.06018.24
5.6.190.0170.08020.57
5.6.180.0270.03720.33
5.6.170.0200.08320.45
5.6.160.0170.07020.39
5.6.150.0070.04018.26
5.6.140.0100.03318.15
5.6.130.0200.07018.17
5.6.120.0070.04721.11
5.6.110.0030.09720.98
5.6.100.0100.03321.02
5.6.90.0030.04321.02
5.6.80.0070.03720.39
5.5.350.0200.07020.39
5.5.340.0100.07717.94
5.5.330.0030.04720.41
5.5.320.0430.04320.27
5.5.310.0330.07020.37
5.5.300.0100.06717.95
5.5.290.0100.05317.92
5.5.280.0130.08320.91
5.5.270.0030.09020.69
5.5.260.0070.07720.88
5.5.250.0030.05720.70
5.5.240.0230.07020.08

preferences:
41.44 ms | 400 KiB | 5 Q