3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input='49.99'; $floor=floor($input); $tens=round($input,-1); echo $floor.' '.$tens."\n"; function getClosest($search, $arr) { $closest = null; foreach($arr as $item) { if($closest == null || abs($search - $closest) > abs($item - $search)) { $closest = $item; } } return $closest; } function roundToValues( $tax, array $possibleTaxes ) { $differences = array(); foreach( $possibleTaxes as $possibleTax) { $differences[ $possibleTax ] = abs($possibleTax - $tax); } return array_search(min($differences), $differences); } $array = [ '500' => '200-500', '200' => '100-200', '100' => '50-100', '50' => '20-50', '20' => '0-20', '0' => '0', ]; $array = [ '0' => '0', '20' => '0-20', '50' => '20-50', '100' => '50-100', '200' => '100-200', '500' => '200-500', ]; print_r($array); echo getClosest($input,$array).' '.roundToValues($input,$array);

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.0100.01018.68
8.3.50.0040.01622.05
8.3.40.0120.00318.84
8.3.30.0080.00619.06
8.3.20.0040.00420.29
8.3.10.0040.00421.93
8.3.00.0060.00319.92
8.2.180.0150.00616.48
8.2.170.0090.00622.96
8.2.160.0030.01020.47
8.2.150.0120.00324.18
8.2.140.0030.00624.66
8.2.130.0120.00626.16
8.2.120.0040.00421.15
8.2.110.0090.00022.10
8.2.100.0060.00621.01
8.2.90.0030.00519.34
8.2.80.0060.00317.97
8.2.70.0080.00017.75
8.2.60.0070.00418.16
8.2.50.0060.00318.07
8.2.40.0040.00418.31
8.2.30.0000.00918.10
8.2.20.0040.00417.79
8.2.10.0040.00418.16
8.2.00.0070.00017.80
8.1.280.0080.00625.92
8.1.270.0090.00022.10
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.92
8.1.230.0040.00819.14
8.1.220.0060.00317.74
8.1.210.0080.00018.77
8.1.200.0030.00617.60
8.1.190.0050.00317.25
8.1.180.0000.00818.10
8.1.170.0000.00818.70
8.1.160.0040.00422.20
8.1.150.0040.00418.91
8.1.140.0070.00317.63
8.1.130.0030.00317.88
8.1.120.0070.00017.51
8.1.110.0050.00217.53
8.1.100.0040.00417.42
8.1.90.0000.00817.47
8.1.80.0030.00317.53
8.1.70.0000.00717.43
8.1.60.0030.00517.64
8.1.50.0090.00017.49
8.1.40.0050.00317.60
8.1.30.0060.00317.66
8.1.20.0000.00817.82
8.1.10.0060.00317.66
8.1.00.0040.00417.55
8.0.300.0070.00018.77
8.0.290.0040.00416.74
8.0.280.0030.00318.44
8.0.270.0000.00717.25
8.0.260.0070.00017.29
8.0.250.0070.00017.16
8.0.240.0000.00717.11
8.0.230.0070.00017.06
8.0.220.0000.00717.00
8.0.210.0050.00317.02
8.0.200.0000.00817.07
8.0.190.0000.00817.09
8.0.180.0070.00017.03
8.0.170.0040.00417.06
8.0.160.0000.00716.92
8.0.150.0050.00216.95
8.0.140.0030.00816.92
8.0.130.0030.00313.47
8.0.120.0000.00816.88
8.0.110.0080.00017.07
8.0.100.0050.00316.91
8.0.90.0080.00016.83
8.0.80.0090.00616.95
8.0.70.0070.00016.91
8.0.60.0040.00417.06
8.0.50.0050.00317.04
8.0.30.0100.01017.31
8.0.20.0080.01117.40
8.0.10.0050.00317.18
8.0.00.0130.00617.06
7.4.330.0000.00515.21
7.4.320.0000.00616.43
7.4.300.0030.00316.54
7.4.290.0040.00416.58
7.4.280.0030.00516.56
7.4.270.0070.00016.59
7.4.260.0070.00016.55
7.4.250.0040.00416.55
7.4.240.0010.00616.64
7.4.230.0000.00716.49
7.4.220.0080.01216.70
7.4.210.0040.01116.54
7.4.200.0070.00016.60
7.4.160.0060.01016.69
7.4.150.0070.01117.40
7.4.140.0130.00717.86
7.4.130.0100.01016.70
7.4.120.0100.00816.72
7.4.110.0030.01916.70
7.4.100.0140.00416.60
7.4.90.0070.01016.61
7.4.80.0030.01319.39
7.4.70.0030.01316.52
7.4.60.0090.00916.58
7.4.50.0040.00416.26
7.4.40.0030.01416.50
7.4.30.0060.00816.69
7.4.00.0100.00714.98
7.3.330.0040.00413.34
7.3.320.0000.00613.42
7.3.310.0030.00316.53
7.3.300.0000.00716.35
7.3.290.0160.00416.49
7.3.280.0090.00816.49
7.3.270.0090.00917.40
7.3.260.0120.00516.48
7.3.250.0140.00516.63
7.3.240.0090.00916.51
7.3.230.0100.00716.63
7.3.210.0090.00916.69
7.3.200.0070.01019.39
7.3.190.0100.01016.48
7.3.180.0040.01216.70
7.3.170.0070.01416.41
7.3.160.0060.01216.60
7.3.120.0040.00415.08
7.2.330.0060.01216.75
7.2.320.0100.01316.77
7.2.310.0130.00316.79
7.2.300.0000.01516.84
7.2.290.0040.01316.68
7.2.60.0090.00616.79
7.2.00.0040.00719.28
7.1.200.0040.00715.77
7.1.100.0090.00318.10
7.1.70.0030.00317.27
7.1.60.0030.02019.25
7.1.50.0110.00734.75
7.1.00.0030.07722.33
7.0.200.0000.00816.62
7.0.140.0000.07722.08
7.0.60.0100.07719.99
7.0.50.0100.07017.90
7.0.40.0070.08720.09
7.0.30.0200.07320.21
7.0.20.0300.06320.05
7.0.10.0030.07720.10
7.0.00.0100.08320.11
5.6.280.0000.07721.08
5.6.210.0000.07720.63
5.6.200.0000.05018.23
5.6.190.0070.09320.50
5.6.180.3770.04320.52
5.6.170.0330.07320.64
5.6.160.0100.05320.53
5.6.150.0130.07718.18
5.6.140.0100.07718.18
5.6.130.0030.04718.15
5.6.120.0070.04721.00
5.6.110.0170.07320.90
5.6.100.0270.05720.90
5.6.90.0130.07720.97
5.6.80.0070.04720.39
5.6.70.4470.03720.51
5.5.350.0030.07320.48
5.5.340.0070.07317.99
5.5.330.0130.05020.47
5.5.320.3400.04320.27
5.5.310.0330.07320.40
5.5.300.0030.08718.07
5.5.290.0100.05317.98
5.5.280.0070.08320.77
5.5.270.0070.07720.77
5.5.260.0070.08720.97
5.5.250.0000.04720.46
5.5.240.0230.07320.05
5.4.450.0300.04319.39
5.4.440.0130.05019.42
5.4.430.0230.04319.19
5.4.420.0200.03719.27
5.4.410.0130.04019.15
5.4.400.0470.03319.22
5.4.390.0130.04718.95
5.4.380.0170.05318.76
5.4.370.0200.06718.54
5.4.360.0130.05318.69
5.4.350.0200.05018.76
5.4.340.0300.03718.76
5.4.320.0020.04112.52
5.4.310.0050.04012.52
5.4.300.0100.04412.52
5.4.290.0120.04812.52
5.4.280.0060.04412.41
5.4.270.0070.03812.41
5.4.260.0100.03412.41
5.4.250.0100.03412.41
5.4.240.0050.03812.41
5.4.230.0100.03412.41
5.4.220.0070.03612.40
5.4.210.0070.03512.41
5.4.200.0120.04312.41
5.4.190.0100.04812.40
5.4.180.0080.04912.40
5.4.170.0060.03612.41
5.4.160.0040.03712.40
5.4.150.0080.03512.40
5.4.140.0060.03812.08
5.4.130.0090.03312.07
5.4.120.0090.03312.02
5.4.110.0050.03712.02
5.4.100.0080.03412.02
5.4.90.0080.03612.03
5.4.80.0040.04012.03
5.4.70.0050.03612.02
5.4.60.0080.04312.02
5.4.50.0050.03712.02
5.4.40.0100.03812.01
5.4.30.0110.03212.01
5.4.20.0040.04012.01
5.4.10.0060.03612.00
5.4.00.0060.04311.49
5.3.290.0080.03712.80
5.3.280.0070.03812.70
5.3.270.0060.04012.72
5.3.260.0040.04212.71
5.3.250.0080.03612.72
5.3.240.0040.04612.72
5.3.230.0020.04212.70
5.3.220.0060.03812.68
5.3.210.0060.04012.68
5.3.200.0070.03612.68
5.3.190.0070.04012.67
5.3.180.0090.03512.67
5.3.170.0080.03612.67
5.3.160.0060.04112.67
5.3.150.0130.04712.67
5.3.140.0100.04012.66
5.3.130.0090.03712.66
5.3.120.0060.03912.66
5.3.110.0070.04312.66
5.3.100.0070.03912.13
5.3.90.0070.03512.11
5.3.80.0050.03812.10
5.3.70.0050.03912.11
5.3.60.0060.03612.09
5.3.50.0080.03512.03
5.3.40.0080.03712.05
5.3.30.0060.03711.99
5.3.20.0090.03211.77
5.3.10.0090.03911.74
5.3.00.0070.03611.73
5.2.170.0020.0339.23
5.2.160.0030.0309.23
5.2.150.0060.0349.23
5.2.140.0090.0299.22
5.2.130.0070.0389.19
5.2.120.0050.0299.18
5.2.110.0060.0289.20
5.2.100.0060.0289.18
5.2.90.0080.0279.19
5.2.80.0030.0329.18
5.2.70.0080.0289.18
5.2.60.0060.0309.14
5.2.50.0020.0339.11
5.2.40.0060.0279.09
5.2.30.0040.0309.05
5.2.20.0100.0239.05
5.2.10.0050.0278.95
5.2.00.0040.0308.82
5.1.60.0050.0238.10
5.1.50.0040.0258.10
5.1.40.0030.0278.08
5.1.30.0090.0308.43
5.1.20.0050.0268.45
5.1.10.0050.0308.18
5.1.00.0080.0258.18
5.0.50.0030.0216.66
5.0.40.0040.0256.51
5.0.30.0040.0326.33
5.0.20.0040.0186.29
5.0.10.0040.0296.27
5.0.00.0110.0316.26
4.4.90.0020.0174.78
4.4.80.0020.0164.76
4.4.70.0040.0204.75
4.4.60.0040.0224.75
4.4.50.0050.0144.77
4.4.40.0010.0314.71
4.4.30.0030.0154.76
4.4.20.0020.0174.85
4.4.10.0030.0154.85
4.4.00.0020.0264.76
4.3.110.0060.0124.67
4.3.100.0020.0164.66
4.3.90.0020.0154.63
4.3.80.0020.0254.58
4.3.70.0020.0154.63
4.3.60.0030.0144.62
4.3.50.0040.0144.63
4.3.40.0030.0244.54
4.3.30.0010.0173.32
4.3.20.0010.0173.30
4.3.10.0020.0163.24
4.3.00.0130.01315.26

preferences:
37.95 ms | 401 KiB | 5 Q