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', ]; 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.0110.01118.43
8.3.50.0120.00621.93
8.3.40.0110.00418.92
8.3.30.0110.00319.23
8.3.20.0020.00520.29
8.3.10.0040.00421.87
8.3.00.0000.00819.81
8.2.180.0150.00616.50
8.2.170.0110.00322.96
8.2.160.0100.00320.35
8.2.150.0090.00024.18
8.2.140.0000.00824.66
8.2.130.0110.00726.16
8.2.120.0050.00321.09
8.2.110.0030.00720.66
8.2.100.0090.00317.97
8.2.90.0040.00418.17
8.2.80.0000.00817.97
8.2.70.0060.00317.63
8.2.60.0040.00418.05
8.2.50.0040.00418.07
8.2.40.0030.00619.89
8.2.30.0070.00418.16
8.2.20.0040.00417.86
8.2.10.0040.00418.11
8.2.00.0050.00317.92
8.1.280.0110.00425.92
8.1.270.0080.00022.08
8.1.260.0050.00226.35
8.1.250.0040.00428.09
8.1.240.0030.00622.02
8.1.230.0110.00020.97
8.1.220.0030.00517.79
8.1.210.0040.00418.87
8.1.200.0000.01017.47
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0060.00318.69
8.1.160.0000.00722.01
8.1.150.0080.00018.86
8.1.140.0020.00517.51
8.1.130.0070.00017.52
8.1.120.0000.00717.54
8.1.110.0000.00717.59
8.1.100.0040.00417.54
8.1.90.0050.00217.52
8.1.80.0000.00717.45
8.1.70.0000.00717.46
8.1.60.0000.00817.57
8.1.50.0060.00317.57
8.1.40.0000.00817.48
8.1.30.0060.00317.74
8.1.20.0040.00417.75
8.1.10.0000.00817.62
8.1.00.0000.00717.46
8.0.300.0030.00620.21
8.0.290.0040.00416.88
8.0.280.0070.00018.50
8.0.270.0000.00717.23
8.0.260.0040.00418.61
8.0.250.0030.00317.00
8.0.240.0000.00617.08
8.0.230.0030.00317.11
8.0.220.0080.00017.00
8.0.210.0080.00016.89
8.0.200.0000.00717.07
8.0.190.0000.00717.11
8.0.180.0040.00416.93
8.0.170.0050.00316.92
8.0.160.0070.00016.98
8.0.150.0050.00216.98
8.0.140.0100.00017.04
8.0.130.0060.00013.45
8.0.120.0080.00016.98
8.0.110.0020.00517.02
8.0.100.0000.00716.88
8.0.90.0040.00416.92
8.0.80.0090.00617.01
8.0.70.0030.00516.97
8.0.60.0040.00416.97
8.0.50.0040.00416.97
8.0.30.0080.01517.33
8.0.20.0110.00717.40
8.0.10.0000.00717.10
8.0.00.0090.00916.82
7.4.330.0020.00215.15
7.4.320.0030.00316.58
7.4.300.0000.00616.56
7.4.290.0080.00016.63
7.4.280.0040.00416.70
7.4.270.0030.00316.57
7.4.260.0080.00316.64
7.4.250.0000.00816.59
7.4.240.0030.00416.66
7.4.230.0000.00616.70
7.4.220.0120.01216.64
7.4.210.0150.00616.69
7.4.200.0070.00016.76
7.4.160.0110.00416.55
7.4.150.0090.00917.40
7.4.140.0060.01217.86
7.4.130.0130.00416.67
7.4.120.0120.00616.59
7.4.110.0110.00816.67
7.4.100.0000.01816.62
7.4.90.0140.00316.81
7.4.80.0170.00319.39
7.4.70.0130.01116.66
7.4.60.0100.00716.65
7.4.50.0040.00416.45
7.4.40.0110.00816.70
7.4.30.0000.01716.66
7.4.00.0090.00614.91
7.3.330.0070.00013.28
7.3.320.0000.00613.31
7.3.310.0030.00316.45
7.3.300.0070.00016.36
7.3.290.0040.01116.55
7.3.280.0120.00716.51
7.3.270.0140.00317.40
7.3.260.0170.00016.37
7.3.250.0110.00916.52
7.3.240.0090.00916.43
7.3.230.0090.00616.52
7.3.210.0120.00616.43
7.3.200.0080.00819.39
7.3.190.0060.00916.54
7.3.180.0100.00716.57
7.3.170.0060.01516.49
7.3.160.0070.01116.57
7.3.120.0090.00617.15
7.3.110.0110.00417.15
7.3.100.0030.01017.15
7.3.90.0070.00717.15
7.3.80.0070.00317.15
7.3.70.0070.00717.15
7.3.60.0030.00617.15
7.3.50.0030.01317.15
7.3.40.0030.01417.15
7.3.30.0060.00917.15
7.3.20.0090.00617.15
7.3.10.0040.00916.97
7.3.00.0070.00716.77
7.2.330.0120.00616.85
7.2.320.0100.01316.87
7.2.310.0090.00916.61
7.2.300.0100.00616.92
7.2.290.0080.00816.58
7.2.240.0070.01017.15
7.2.230.0110.00417.15
7.2.220.0070.00717.15
7.2.210.0030.01217.15
7.2.200.0060.00317.15
7.2.190.0000.01317.15
7.2.180.0070.01017.15
7.2.170.0030.01017.15
7.2.160.0070.01117.15
7.2.150.0000.01517.15
7.2.140.0000.01717.15
7.2.130.0020.01117.08
7.2.120.0060.00317.06
7.2.110.0080.00717.08
7.2.100.0080.00617.06
7.2.90.0030.00817.00
7.2.80.0050.01117.09
7.2.70.0030.01017.09
7.2.60.0050.00817.04
7.2.50.0050.01116.96
7.2.40.0080.00916.96
7.2.30.0050.00517.09
7.2.20.0080.00816.94
7.2.10.0050.00717.08
7.2.00.0060.00917.69
7.1.330.0060.00617.15
7.1.320.0030.01317.15
7.1.310.0060.00317.15
7.1.300.0070.00317.15
7.1.290.0040.01017.15
7.1.280.0060.00717.15
7.1.270.0030.01317.15
7.1.260.0000.01317.15
7.1.250.0030.01116.50
7.1.200.0030.00915.82
7.1.100.0090.00318.21
7.1.70.0030.00717.19
7.1.60.0150.00919.25
7.1.50.0170.02034.77
7.1.00.0000.07722.44
7.0.200.0090.00016.69
7.0.140.0100.06722.18
7.0.60.0000.05019.93
7.0.50.0130.03317.89
7.0.40.0070.09020.06
7.0.30.0370.06720.09
7.0.20.0400.07320.16
7.0.10.0030.09020.08
7.0.00.0000.09020.32
5.6.280.0100.06721.08
5.6.210.0130.07020.46
5.6.200.0100.07718.19
5.6.190.0030.07320.39
5.6.180.3600.03720.39
5.6.170.0170.06020.43
5.6.160.0070.06320.58
5.6.150.0030.04018.23
5.6.140.0070.08318.15
5.6.130.0030.08318.13
5.6.120.0070.04020.90
5.6.110.0070.03720.99
5.6.100.0170.06720.90
5.6.90.0030.04320.95
5.6.80.0030.08020.42
5.5.350.0070.03320.43
5.5.340.0100.07718.05
5.5.330.0130.07020.43
5.5.320.3530.04320.44
5.5.310.0200.04720.30
5.5.300.0100.06317.98
5.5.290.0100.04017.98
5.5.280.0070.05720.81
5.5.270.0070.08320.85
5.5.260.0070.08020.87
5.5.250.0130.03720.58
5.5.240.3970.03320.24
5.4.450.0130.05019.59
5.4.440.0200.05319.42
5.4.430.0230.05019.30
5.4.420.0270.04019.46
5.4.410.0200.04319.48
5.4.400.0300.03318.96
5.4.390.0230.04019.08
5.4.380.0270.04718.54
5.4.370.0200.05018.62
5.4.360.0100.06018.56
5.4.350.0100.08018.63
5.4.340.0130.05318.48
5.4.320.0070.03612.52
5.4.310.0100.03412.51
5.4.300.0040.03912.52
5.4.290.0070.04112.52
5.4.280.0020.04112.41
5.4.270.0050.03912.41
5.4.260.0070.03812.41
5.4.250.0060.04612.41
5.4.240.0070.04612.41
5.4.230.0060.03912.40
5.4.220.0100.03312.41
5.4.210.0050.03812.40
5.4.200.0070.03812.40
5.4.190.0060.03712.40
5.4.180.0110.04812.40
5.4.170.0120.04712.40
5.4.160.0140.04312.40
5.4.150.0120.06012.39
5.4.140.0100.04912.08
5.4.130.0120.04212.07
5.4.120.0100.05512.03
5.4.110.0090.04912.02
5.4.100.0100.04512.03
5.4.90.0090.04912.03
5.4.80.0070.04412.03
5.4.70.0040.03612.02
5.4.60.0060.03512.02
5.4.50.0070.03512.02
5.4.40.0090.03112.01
5.4.30.0060.03512.01
5.4.20.0040.03712.00
5.4.10.0080.03212.01
5.4.00.0120.03111.50
5.3.290.0090.04412.80
5.3.280.0090.03512.71
5.3.270.0070.04012.73
5.3.260.0070.04012.72
5.3.250.0070.04312.72
5.3.240.0070.03912.71
5.3.230.0070.03812.70
5.3.220.0110.07712.68
5.3.210.0100.04112.68
5.3.200.0070.03812.68
5.3.190.0040.04012.68
5.3.180.0060.04812.67
5.3.170.0110.04412.66
5.3.160.0060.04312.67
5.3.150.0110.04512.67
5.3.140.0070.06012.66
5.3.130.0140.05412.66
5.3.120.0130.03712.66
5.3.110.0070.03812.66
5.3.100.0050.03812.13
5.3.90.0080.03512.11
5.3.80.0060.03712.10
5.3.70.0100.03312.10
5.3.60.0060.03612.09
5.3.50.0080.03512.03
5.3.40.0050.03812.03
5.3.30.0040.03611.99
5.3.20.0030.03911.77
5.3.10.0060.03511.74
5.3.00.0060.03611.73
5.2.170.0060.0299.23
5.2.160.0070.0379.23
5.2.150.0070.0299.23
5.2.140.0060.0309.22
5.2.130.0040.0309.19
5.2.120.0070.0269.18
5.2.110.0040.0319.19
5.2.100.0050.0289.18
5.2.90.0050.0289.19
5.2.80.0050.0299.18
5.2.70.0030.0329.18
5.2.60.0050.0309.14
5.2.50.0050.0309.11
5.2.40.0040.0309.09
5.2.30.0060.0329.06
5.2.20.0040.0329.05
5.2.10.0080.0298.95
5.2.00.0070.0288.82
5.1.60.0070.0228.10
5.1.50.0030.0278.10
5.1.40.0050.0248.07
5.1.30.0050.0258.43
5.1.20.0050.0268.45
5.1.10.0020.0318.17
5.1.00.0030.0278.18
5.0.50.0040.0206.65
5.0.40.0050.0206.52
5.0.30.0050.0306.32
5.0.20.0050.0196.29
5.0.10.0060.0256.27
5.0.00.0040.0376.26
4.4.90.0030.0224.78
4.4.80.0060.0184.76
4.4.70.0010.0184.75
4.4.60.0050.0134.75
4.4.50.0030.0154.77
4.4.40.0020.0264.71
4.4.30.0050.0134.76
4.4.20.0020.0164.84
4.4.10.0060.0124.85
4.4.00.0040.0234.76
4.3.110.0050.0174.67
4.3.100.0010.0174.66
4.3.90.0030.0144.64
4.3.80.0020.0264.58
4.3.70.0070.0154.63
4.3.60.0040.0154.63
4.3.50.0010.0184.63
4.3.40.0030.0244.53
4.3.30.0030.0153.32
4.3.20.0010.0173.30
4.3.10.0020.0163.25
4.3.00.0000.01715.26

preferences:
40.22 ms | 401 KiB | 5 Q