3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input='46.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( $search, array $arr ) { $differences = array(); foreach( $arr as $item) { $differences[ $item ] = abs($item - $search); } return array_search(min($differences), $differences); } $array = [ '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.0140.00718.56
8.3.50.0110.00521.93
8.3.40.0110.00418.84
8.3.30.0090.00619.18
8.3.20.0000.00720.41
8.3.10.0040.00421.86
8.3.00.0040.00417.87
8.2.180.0130.00716.63
8.2.170.0040.01122.96
8.2.160.0110.00420.28
8.2.150.0110.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0050.00321.04
8.2.110.0030.00722.39
8.2.100.0060.00617.97
8.2.90.0050.00319.22
8.2.80.0030.00617.97
8.2.70.0040.00417.63
8.2.60.0000.00818.05
8.2.50.0000.00818.07
8.2.40.0050.00320.01
8.2.30.0070.00318.18
8.2.20.0000.00817.90
8.2.10.0040.00418.10
8.2.00.0030.00617.75
8.1.280.0060.00925.92
8.1.270.0030.00523.96
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.91
8.1.230.0040.00719.30
8.1.220.0040.00417.89
8.1.210.0030.00518.77
8.1.200.0130.00017.34
8.1.190.0000.00817.12
8.1.180.0030.00518.10
8.1.170.0000.00818.60
8.1.160.0000.00721.95
8.1.150.0080.00018.98
8.1.140.0050.00217.42
8.1.130.0030.00517.88
8.1.120.0000.00717.50
8.1.110.0050.00317.45
8.1.100.0000.00817.50
8.1.90.0030.00317.45
8.1.80.0000.00717.59
8.1.70.0080.00017.51
8.1.60.0040.00417.55
8.1.50.0000.00817.61
8.1.40.0040.00417.54
8.1.30.0030.00617.75
8.1.20.0000.00817.63
8.1.10.0030.00517.67
8.1.00.0040.00417.43
8.0.300.0000.00718.77
8.0.290.0040.00416.74
8.0.280.0030.00318.44
8.0.270.0050.00317.29
8.0.260.0000.00817.31
8.0.250.0000.00717.07
8.0.240.0000.00717.03
8.0.230.0050.00217.06
8.0.220.0000.00716.93
8.0.210.0030.00616.99
8.0.200.0030.00316.99
8.0.190.0040.00416.99
8.0.180.0000.00717.03
8.0.170.0070.00016.94
8.0.160.0060.00316.89
8.0.150.0080.00016.91
8.0.140.0030.00516.96
8.0.130.0030.00313.43
8.0.120.0080.00016.87
8.0.110.0000.00816.91
8.0.100.0000.00716.96
8.0.90.0040.00416.89
8.0.80.0090.00617.11
8.0.70.0040.00416.85
8.0.60.0000.00816.98
8.0.50.0050.00316.88
8.0.30.0050.01317.18
8.0.20.0080.01017.46
8.0.10.0000.00717.20
8.0.00.0060.01216.88
7.4.330.0050.00015.09
7.4.320.0060.00016.55
7.4.300.0000.00716.55
7.4.290.0040.00416.75
7.4.280.0040.00416.69
7.4.270.0030.00316.67
7.4.260.0030.00616.51
7.4.250.0040.00416.54
7.4.240.0020.00516.52
7.4.230.0070.00016.68
7.4.220.0090.00916.57
7.4.210.0120.00916.52
7.4.200.0000.00716.48
7.4.160.0080.00816.72
7.4.150.0140.00317.40
7.4.140.0120.00917.86
7.4.130.0070.01016.54
7.4.120.0140.00716.67
7.4.110.0160.00716.63
7.4.100.0110.01216.65
7.4.90.0120.00616.44
7.4.80.0100.01119.39
7.4.70.0120.00516.65
7.4.60.0060.00916.61
7.4.50.0030.00516.34
7.4.40.0100.00716.55
7.4.30.0100.00716.48
7.4.00.0030.01415.14
7.3.330.0030.00313.49
7.3.320.0030.00313.47
7.3.310.0000.00716.48
7.3.300.0070.00016.54
7.3.290.0030.01016.56
7.3.280.0120.00716.52
7.3.270.0160.00717.40
7.3.260.0090.00916.71
7.3.250.0070.01116.67
7.3.240.0070.01016.39
7.3.230.0030.01316.61
7.3.210.0120.00616.63
7.3.200.0140.00319.39
7.3.190.0100.01016.69
7.3.180.0080.00816.59
7.3.170.0080.00916.59
7.3.160.0110.00716.55
7.3.120.0030.01014.88
7.2.330.0180.00616.84
7.2.320.0120.01016.76
7.2.310.0060.01016.64
7.2.300.0120.00316.58
7.2.290.0060.01316.75
7.2.60.0060.00916.99
7.2.00.0120.00818.77
7.1.200.0060.00615.93
7.1.100.0060.00618.10
7.1.70.0060.00317.05
7.1.60.0070.01719.25
7.1.50.0250.01334.74
7.1.00.0070.07322.53
7.0.200.0000.00716.62
7.0.140.0070.07021.95
7.0.60.0100.07319.98
7.0.50.0030.04017.89
7.0.40.0100.08320.23
7.0.30.0270.05720.10
7.0.20.0300.07320.33
7.0.10.0270.05320.23
7.0.00.0100.06020.07
5.6.280.0000.07720.91
5.6.210.0030.04020.71
5.6.200.0130.04318.13
5.6.190.0070.08020.41
5.6.180.0330.03720.61
5.6.170.0430.04320.44
5.6.160.0100.06720.62
5.6.150.0000.04318.23
5.6.140.0070.08018.19
5.6.130.0030.04318.12
5.6.120.0000.04321.02
5.6.110.0100.04321.02
5.6.100.0130.07020.99
5.6.90.0100.07021.01
5.6.80.0070.06720.29
5.6.70.0470.06320.38
5.5.350.0030.07320.41
5.5.340.0100.07717.98
5.5.330.0100.08720.57
5.5.320.0500.06320.35
5.5.310.0370.05320.41
5.5.300.0070.05717.96
5.5.290.0170.06317.96
5.5.280.0100.08320.69
5.5.270.0030.06020.68
5.5.260.0070.07020.65
5.5.250.0100.07020.47
5.5.240.0030.03720.16
5.4.450.0300.04019.42
5.4.440.0230.04719.61
5.4.430.0300.03719.27
5.4.420.0230.03719.54
5.4.410.0230.04319.42
5.4.400.0170.04019.15
5.4.390.0170.04719.24
5.4.380.0100.06018.79
5.4.370.0070.06018.61
5.4.360.0070.06018.49
5.4.350.0170.05318.77
5.4.340.0200.05018.56
5.4.320.0070.04112.52
5.4.310.0070.03712.51
5.4.300.0070.03612.52
5.4.290.0070.03712.51
5.4.280.0060.03512.41
5.4.270.0090.03512.41
5.4.260.0060.03812.41
5.4.250.0110.03412.41
5.4.240.0060.03612.41
5.4.230.0100.03812.40
5.4.220.0070.03612.41
5.4.210.0090.03312.40
5.4.200.0060.03812.40
5.4.190.0080.03512.39
5.4.180.0060.03712.39
5.4.170.0060.03612.40
5.4.160.0050.03912.40
5.4.150.0100.03812.40
5.4.140.0050.04012.08
5.4.130.0060.03612.07
5.4.120.0040.03712.03
5.4.110.0070.03512.02
5.4.100.0070.03412.02
5.4.90.0080.03412.02
5.4.80.0060.03712.02
5.4.70.0080.03412.02
5.4.60.0040.03712.01
5.4.50.0070.03512.02
5.4.40.0050.03612.00
5.4.30.0090.03612.00
5.4.20.0130.05612.00
5.4.10.0090.04512.00
5.4.00.0050.03811.49
5.3.290.0060.05712.80
5.3.280.0040.04112.71
5.3.270.0090.04712.72
5.3.260.0050.04012.72
5.3.250.0080.03712.72
5.3.240.0050.04112.72
5.3.230.0080.03612.71
5.3.220.0080.04912.68
5.3.210.0060.03812.68
5.3.200.0040.03812.68
5.3.190.0110.03512.68
5.3.180.0070.04112.67
5.3.170.0070.03712.67
5.3.160.0070.04412.67
5.3.150.0080.03612.68
5.3.140.0050.03812.66
5.3.130.0090.03612.66
5.3.120.0100.03612.66
5.3.110.0060.04012.66
5.3.100.0040.04012.13
5.3.90.0090.03512.11
5.3.80.0030.03912.11
5.3.70.0030.04012.10
5.3.60.0070.03612.09
5.3.50.0050.04012.03
5.3.40.0050.03912.03
5.3.30.0040.03612.00
5.3.20.0030.03811.77
5.3.10.0070.03311.74
5.3.00.0060.03811.73
5.2.170.0050.0309.23
5.2.160.0070.0269.23
5.2.150.0060.0299.23
5.2.140.0060.0299.23
5.2.130.0050.0289.18
5.2.120.0050.0289.19
5.2.110.0060.0289.19
5.2.100.0040.0299.19
5.2.90.0090.0259.19
5.2.80.0050.0329.18
5.2.70.0050.0359.18
5.2.60.0070.0279.14
5.2.50.0090.0269.11
5.2.40.0070.0299.09
5.2.30.0070.0289.05
5.2.20.0080.0269.05
5.2.10.0050.0288.96
5.2.00.0060.0288.82
5.1.60.0040.0268.10
5.1.50.0020.0278.10
5.1.40.0060.0258.08
5.1.30.0080.0238.43
5.1.20.0090.0228.45
5.1.10.0070.0238.18
5.1.00.0060.0248.18
5.0.50.0030.0226.66
5.0.40.0040.0226.51
5.0.30.0040.0306.32
5.0.20.0050.0186.29
5.0.10.0050.0226.27
5.0.00.0030.0346.26
4.4.90.0020.0184.77
4.4.80.0050.0144.75
4.4.70.0060.0134.76
4.4.60.0030.0184.76
4.4.50.0040.0144.77
4.4.40.0010.0284.71
4.4.30.0040.0144.76
4.4.20.0030.0154.84
4.4.10.0020.0174.85
4.4.00.0020.0274.75
4.3.110.0020.0204.67
4.3.100.0030.0154.67
4.3.90.0030.0184.63
4.3.80.0030.0254.58
4.3.70.0010.0174.63
4.3.60.0040.0144.63
4.3.50.0020.0164.63
4.3.40.0020.0274.54
4.3.30.0030.0153.32
4.3.20.0020.0163.30
4.3.10.0010.0163.24
4.3.00.0030.01715.26

preferences:
41.08 ms | 401 KiB | 5 Q