3v4l.org

run code in 300+ PHP versions simultaneously
<?php function money_round ($amount) { # convert to string $string = (string)$amount; ## find out if negative ## if (substr($string, 0, 1) == '-') { $negative = true; $string = substr($string, 1, strlen($string) - 1); } else { $negative = false; } # if there's no decimal point add one on the end if (substr_count($string, '.') == 0) { $string .= '.'; } # add a few trailing '0's in case there aren't enough there already $string .= '000'; # find the decimal point $dotpos = strpos($string, '.'); # separate pounds $pounds = substr($string, 0, $dotpos); # separate pence $pence = substr($string, $dotpos + 1, 2); # find out how many tenths of a penny $tenths = substr($string, $dotpos + 3, 1); if ($tenths >= 5) { $pence++; if ($pence == 100) { $pence = '0'; $pounds++; } if ($pence < 10) { $pence = '0' . $pence; } } if ($negative) { return '-' . $pounds . '.' . $pence; } else { return $pounds . '.' . $pence; } } echo money_round(33333.333333333);

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.0120.00918.31
8.3.50.0100.01318.30
8.3.40.0090.00918.85
8.3.30.0110.00419.17
8.3.20.0040.00420.31
8.3.10.0040.00423.48
8.3.00.0000.00819.19
8.2.180.0130.00618.16
8.2.170.0070.00722.96
8.2.160.0140.00022.16
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00021.02
8.2.110.0030.00620.58
8.2.100.0090.00317.91
8.2.90.0040.00417.75
8.2.80.0030.00518.72
8.2.70.0090.00017.93
8.2.60.0040.00418.22
8.2.50.0000.00719.37
8.2.40.0080.00021.05
8.2.30.0000.00719.40
8.2.20.0000.00717.77
8.2.10.0000.00818.21
8.2.00.0030.00717.64
8.1.280.0150.00025.92
8.1.270.0040.00418.87
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0080.00421.91
8.1.230.0080.00322.76
8.1.220.0030.00617.79
8.1.210.0030.00618.77
8.1.200.0060.00317.35
8.1.190.0040.00417.23
8.1.180.0000.00818.96
8.1.170.0000.00918.50
8.1.160.0030.00619.04
8.1.150.0000.00818.85
8.1.140.0000.00817.39
8.1.130.0090.00017.85
8.1.120.0040.00417.53
8.1.110.0040.00417.54
8.1.100.0070.00017.44
8.1.90.0030.00317.46
8.1.80.0000.00717.49
8.1.70.0040.00417.39
8.1.60.0030.00617.62
8.1.50.0030.00617.47
8.1.40.0000.00817.53
8.1.30.0040.00417.50
8.1.20.0000.00817.65
8.1.10.0030.00617.58
8.1.00.0040.00417.29
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0000.00718.48
8.0.270.0050.00517.16
8.0.260.0000.00717.29
8.0.250.0030.00316.88
8.0.240.0000.00616.96
8.0.230.0000.00816.98
8.0.220.0030.00416.91
8.0.210.0030.00316.84
8.0.200.0030.00317.02
8.0.190.0040.00416.97
8.0.180.0050.00216.83
8.0.170.0070.00016.79
8.0.160.0000.00716.94
8.0.150.0040.00416.98
8.0.140.0050.00316.79
8.0.130.0040.00413.36
8.0.120.0050.00316.83
8.0.110.0090.00016.85
8.0.100.0070.00016.90
8.0.90.0040.00316.89
8.0.80.0110.00316.97
8.0.70.0030.00516.89
8.0.60.0040.00416.80
8.0.50.0040.00416.98
8.0.30.0120.00916.93
8.0.20.0140.00517.40
8.0.10.0000.00717.10
8.0.00.0050.01216.79
7.4.330.0000.00615.03
7.4.320.0000.00716.55
7.4.300.0060.00016.71
7.4.290.0000.00716.42
7.4.280.0000.00816.63
7.4.270.0000.00716.52
7.4.260.0030.00316.58
7.4.250.0070.00016.57
7.4.240.0030.00316.54
7.4.230.0030.00316.29
7.4.220.0090.00916.70
7.4.210.0180.00316.51
7.4.200.0040.00416.57
7.4.160.0030.01316.63
7.4.150.0100.01317.40
7.4.140.0100.00717.86
7.4.130.0100.01116.44
7.4.120.0100.00816.60
7.4.110.0130.01016.45
7.4.100.0090.00916.52
7.4.90.0100.00616.52
7.4.80.0120.00619.39
7.4.70.0080.01216.42
7.4.60.0090.00816.55
7.4.50.0030.00316.20
7.4.40.0030.01416.54
7.4.30.0030.01516.47
7.4.00.0070.01014.93
7.3.330.0000.00613.15
7.3.320.0030.00313.16
7.3.310.0040.00416.26
7.3.300.0040.00416.40
7.3.290.0050.00916.28
7.3.280.0060.01116.29
7.3.270.0120.00617.40
7.3.260.0000.01716.73
7.3.250.0060.01116.56
7.3.240.0060.01316.61
7.3.230.0100.00616.62
7.3.210.0060.01416.50
7.3.200.0100.00719.39
7.3.190.0100.01016.51
7.3.180.0100.00616.40
7.3.170.0100.01016.41
7.3.160.0120.00316.61
7.3.00.0100.00716.70
7.2.330.0030.01616.73
7.2.320.0090.00916.59
7.2.310.0100.00716.50
7.2.300.0100.01316.82
7.2.290.0080.00816.55
7.2.130.0160.00016.96
7.2.120.0140.00416.72
7.2.110.0110.00416.53
7.2.100.0090.00616.91
7.2.90.0120.00316.93
7.2.80.0070.00716.76
7.2.70.0070.01017.02
7.2.60.0080.00716.99
7.2.50.0130.00716.95
7.2.40.0100.00717.03
7.2.30.0120.00616.81
7.2.20.0140.00716.73
7.2.10.0130.01016.74
7.2.00.0120.00518.22
7.1.250.0120.00015.71
7.1.240.0100.00915.68
7.1.230.0100.00715.59
7.1.220.0140.00715.62
7.1.210.0110.00815.59
7.1.200.0100.00415.85
7.1.190.0140.00315.57
7.1.180.0090.00315.91
7.1.170.0150.00015.92
7.1.160.0080.00315.66
7.1.150.0170.00015.41
7.1.140.0120.00415.78
7.1.130.0090.00615.57
7.1.120.0060.01315.85
7.1.110.0120.00615.81
7.1.100.0090.00916.96
7.1.90.0110.00315.66
7.1.80.0120.00615.84
7.1.70.0090.00816.51
7.1.60.0110.00517.50
7.1.50.0060.01416.38
7.1.40.0130.00315.48
7.1.30.0110.00715.39
7.1.20.0150.00615.52
7.1.10.0100.01015.64
7.1.00.0080.04319.08
7.0.330.0090.00315.15
7.0.320.0070.01015.36
7.0.310.0090.00915.32
7.0.300.0070.00715.48
7.0.290.0110.00415.38
7.0.280.0100.00315.37
7.0.270.0090.00615.30
7.0.260.0100.00715.30
7.0.250.0090.00615.07
7.0.240.0030.01015.45
7.0.230.0110.00715.30
7.0.220.0070.00715.13
7.0.210.0110.00415.28
7.0.200.0080.00715.93
7.0.190.0090.00615.02
7.0.180.0100.00715.46
7.0.170.0110.00715.25
7.0.160.0130.00415.09
7.0.150.0070.01115.37
7.0.140.0040.02518.58
7.0.130.0170.00315.29
7.0.120.0110.00415.42
7.0.110.0100.00815.30
7.0.100.0150.00315.43
7.0.90.0130.00415.02
7.0.80.0070.01315.36
7.0.70.0100.00715.18
7.0.60.0100.03617.59
7.0.50.0030.04216.67
7.0.40.0050.05016.85
7.0.30.0210.04116.70
7.0.20.0130.02316.83
7.0.10.0070.02516.76
7.0.00.0120.02716.67
5.6.380.0070.00714.12
5.6.370.0070.00414.11
5.6.360.0110.00414.43
5.6.350.0070.00214.49
5.6.340.0100.00814.77
5.6.330.0160.00614.17
5.6.320.0070.00714.41
5.6.310.0000.01314.02
5.6.300.0040.01614.26
5.6.290.0120.00314.38
5.6.280.0090.03817.65
5.6.270.0050.01314.13
5.6.260.0000.01714.05
5.6.250.0070.01013.96
5.6.240.0070.01114.39
5.6.230.0060.01314.34
5.6.220.0060.01214.03
5.6.210.0110.04417.54
5.6.200.0140.03716.26
5.6.190.0090.03917.46
5.6.180.0250.03517.44
5.6.170.0130.04117.34
5.6.160.0020.03817.41
5.6.150.0020.03616.23
5.6.140.0120.02516.23
5.6.130.0110.03416.37
5.6.120.0020.02717.72
5.6.110.0100.04417.80
5.6.100.0180.03317.68
5.6.90.0020.03617.55
5.6.80.0050.03417.21
5.6.70.0110.00014.18
5.6.60.0070.00314.41
5.6.50.0030.00914.24
5.6.40.0090.00613.97
5.6.30.0000.01414.46
5.6.20.0030.00914.22
5.6.10.0070.01013.90
5.6.00.0130.00314.11
5.5.380.0000.01311.28
5.5.370.0070.00711.27
5.5.360.0060.00611.09
5.5.350.0170.03615.72
5.5.340.0040.05114.59
5.5.330.0080.04315.64
5.5.320.0230.02215.54
5.5.310.0130.03515.68
5.5.300.0070.02014.51
5.5.290.0080.03714.53
5.5.280.0080.04415.93
5.5.270.0090.04515.83
5.5.260.0050.04515.80
5.5.250.0050.03515.52
5.5.240.0030.04415.63
5.5.230.0120.00310.88
5.5.220.0030.00610.89
5.5.210.0060.00611.14
5.5.200.0060.01210.94
5.5.190.0090.00411.33
5.5.180.0120.00010.89
5.5.170.0120.00410.93
5.5.160.0040.01411.23
5.5.150.0110.00211.07
5.5.140.0040.00410.86
5.5.130.0070.00711.16
5.5.120.0000.01411.05
5.5.110.0030.00710.87
5.5.100.0120.00011.07
5.5.90.0000.00810.60
5.5.80.0000.00810.93
5.5.70.0030.00510.87
5.5.60.0030.01011.11
5.5.50.0050.00911.06
5.5.40.0030.00811.08
5.5.30.0040.00411.21
5.5.20.0070.00310.84
5.5.10.0070.00210.82
5.5.00.0000.00811.10
5.4.450.0390.02615.35
5.4.440.0330.02915.14
5.4.430.0260.03315.10
5.4.420.0370.03515.46
5.4.410.0470.02715.04
5.4.400.0370.02914.89
5.4.390.0170.02814.78
5.4.380.0190.02514.88
5.4.370.0170.02814.73
5.4.360.0120.03514.85
5.4.350.0130.03414.80
5.4.340.0170.03114.75
5.4.330.0000.01210.96
5.4.320.0150.03314.88
5.4.310.0180.03514.78
5.4.300.0150.03314.79
5.4.290.0180.03014.86
5.4.280.0120.03215.03
5.4.270.0100.03614.88
5.4.260.0140.03414.93
5.4.250.0180.02514.87
5.4.240.0130.03014.76
5.4.230.0170.02714.78
5.4.220.0210.03014.91
5.4.210.0140.03215.06
5.4.200.0150.02813.92
5.4.190.0180.02714.88
5.4.180.0150.02914.82
5.4.170.0210.02714.97
5.4.160.0160.02514.96
5.4.150.0160.02815.00
5.4.140.0160.02813.56
5.4.130.0180.02313.91
5.4.120.0180.03013.64
5.4.110.0170.02913.62
5.4.100.0130.03013.75
5.4.90.0180.02613.68
5.4.80.0220.03213.80
5.4.70.0200.02313.69
5.4.60.0200.02613.51
5.4.50.0170.02613.39
5.4.40.0150.03013.63
5.4.30.0120.03213.60
5.4.20.0180.02813.63
5.4.10.0130.03013.61
5.4.00.0130.03213.44
5.3.290.0130.03212.65
5.3.280.0130.03212.57
5.3.270.0200.02612.62
5.3.260.0180.02712.67
5.3.250.0170.02712.80
5.3.240.0150.03212.67
5.3.230.0190.03012.69
5.3.220.0200.02512.55
5.3.210.0160.02912.62
5.3.200.0170.02412.64
5.3.190.0180.02712.52
5.3.180.0170.02812.66
5.3.170.0100.03212.52
5.3.160.0140.02712.62
5.3.150.0170.03212.63
5.3.140.0160.02712.64
5.3.130.0160.03012.70
5.3.120.0140.03012.58
5.3.110.0150.03012.55
5.3.100.0120.03112.34
5.3.90.0170.02712.33
5.3.80.0180.02512.37
5.3.70.0130.02912.32
5.3.60.0180.02712.36
5.3.50.0180.03012.29
5.3.40.0120.03212.17
5.3.30.0120.03012.32
5.3.20.0130.03012.09
5.3.10.0140.02712.03
5.3.00.0130.03012.05
5.2.170.0100.02710.34
5.2.160.0110.02510.49
5.2.150.0100.02510.40
5.2.140.0130.02210.43
5.2.130.0170.01710.32
5.2.120.0120.02210.32
5.2.110.0120.02210.47
5.2.100.0180.01510.42
5.2.90.0080.02410.38
5.2.80.0130.02110.29
5.2.70.0100.02610.35
5.2.60.0110.02310.29
5.2.50.0130.02110.25
5.2.40.0070.02910.25
5.2.30.0100.02410.21
5.2.20.0070.02610.31
5.2.10.0120.02010.18
5.2.00.0080.02510.16
5.1.60.0120.0179.75
5.1.50.0080.0249.75
5.1.40.0120.0229.79
5.1.30.0110.0209.92
5.1.20.0100.0259.92
5.1.10.0150.0169.76
5.1.00.0100.0209.75
5.0.50.0070.0159.09
5.0.40.0050.0178.91
5.0.30.0050.0258.83
5.0.20.0070.0158.83
5.0.10.0050.0188.81
5.0.00.0050.0268.86
4.4.90.0030.0147.98
4.4.80.0080.0097.98
4.4.70.0030.0137.98
4.4.60.0020.0167.98
4.4.50.0050.0137.98
4.4.40.0050.0197.98
4.4.30.0030.0147.98
4.4.20.0030.0147.98
4.4.10.0020.0157.98
4.4.00.0030.0197.98
4.3.110.0080.0107.98
4.3.100.0030.0157.98
4.3.90.0050.0137.98
4.3.80.0020.0207.98
4.3.70.0070.0107.98
4.3.60.0030.0137.98
4.3.50.0030.0137.98
4.3.40.0080.0167.98
4.3.30.0000.0157.98
4.3.20.0020.0157.98
4.3.10.0050.0127.98
4.3.00.0020.0138.33

preferences:
54.21 ms | 400 KiB | 5 Q