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 = array( '0', '20' => '0-20', '50' => '20-50', '100' => '50-100', '200' => '100-200', '500' => '200-500', ); print_r($array); echo getCloser($input,$array); echo 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.40.0000.01418.67
8.3.30.0070.00719.04
8.3.20.0000.00820.44
8.3.10.0000.00822.07
8.3.00.0000.00817.80
8.2.170.0150.00022.96
8.2.160.0070.00720.47
8.2.150.0130.00324.18
8.2.140.0040.00424.66
8.2.130.0060.01226.16
8.2.120.0080.00021.07
8.2.110.0040.00422.23
8.2.100.0060.00618.03
8.2.90.0050.00319.21
8.2.80.0000.00817.97
8.2.70.0000.00817.88
8.2.60.0040.00417.93
8.2.50.0080.00018.07
8.2.40.0000.00819.94
8.2.30.0100.00018.00
8.2.20.0060.00317.80
8.2.10.0040.00418.22
8.2.00.0040.00417.77
8.1.270.0090.00023.85
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0060.00323.97
8.1.230.0080.00419.20
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0100.00317.25
8.1.190.0030.00517.35
8.1.180.0000.00818.10
8.1.170.0030.00518.59
8.1.160.0000.00721.98
8.1.150.0050.00218.95
8.1.140.0050.00217.51
8.1.130.0000.00717.79
8.1.120.0040.00417.52
8.1.110.0040.00417.53
8.1.100.0000.00817.43
8.1.90.0070.00017.45
8.1.80.0040.00417.41
8.1.70.0030.00317.41
8.1.60.0030.00617.52
8.1.50.0060.00317.48
8.1.40.0000.00817.59
8.1.30.0000.00917.64
8.1.20.0020.00517.72
8.1.10.0040.00417.61
8.1.00.0040.00417.50
8.0.300.0070.00018.77
8.0.290.0030.00616.75
8.0.280.0050.00218.49
8.0.270.0030.00317.23
8.0.260.0040.00417.38
8.0.250.0030.00317.11
8.0.240.0000.00717.05
8.0.230.0000.00817.09
8.0.220.0030.00317.01
8.0.210.0000.00816.93
8.0.200.0000.00617.08
8.0.190.0070.00016.99
8.0.180.0000.00716.94
8.0.170.0000.00717.11
8.0.160.0030.00316.95
8.0.150.0070.00016.87
8.0.140.0030.00616.89
8.0.130.0040.00413.40
8.0.120.0030.00616.87
8.0.110.0080.00016.89
8.0.100.0000.00717.06
8.0.90.0000.00717.14
8.0.80.0090.00617.09
8.0.70.0040.00416.92
8.0.60.0040.00417.08
8.0.50.0040.00416.81
8.0.30.0100.01117.22
8.0.20.0120.00617.40
8.0.10.0050.00316.86
8.0.00.0070.01016.89
7.4.330.0000.00515.13
7.4.320.0000.00616.52
7.4.300.0060.00016.66
7.4.290.0030.00316.58
7.4.280.0030.00316.56
7.4.270.0000.00716.52
7.4.260.0040.00716.57
7.4.250.0040.00416.63
7.4.240.0030.00316.57
7.4.230.0030.00316.72
7.4.220.0120.00616.59
7.4.210.0090.00616.59
7.4.200.0030.00316.51
7.4.160.0120.00416.57
7.4.150.0070.01117.40
7.4.140.0090.01117.86
7.4.130.0120.00416.51
7.4.120.0110.01016.67
7.4.110.0140.00316.78
7.4.100.0090.01216.58
7.4.90.0090.00916.51
7.4.80.0090.01219.39
7.4.70.0040.01516.56
7.4.60.0060.01016.60
7.4.50.0000.00816.66
7.4.40.0110.01116.63
7.4.30.0110.00416.40
7.4.00.0060.00614.89
7.3.330.0000.00813.31
7.3.320.0020.00213.30
7.3.310.0070.00016.24
7.3.300.0060.00016.43
7.3.290.0100.00516.51
7.3.280.0080.00816.37
7.3.270.0130.00517.40
7.3.260.0170.00016.42
7.3.250.0120.00616.41
7.3.240.0130.00316.55
7.3.230.0120.00316.42
7.3.210.0070.01116.59
7.3.200.0100.00619.39
7.3.190.0120.00916.63
7.3.180.0110.00416.63
7.3.170.0040.01216.43
7.3.160.0060.00916.41
7.3.120.0070.00714.82
7.2.330.0000.02116.88
7.2.320.0060.01116.86
7.2.310.0100.00716.37
7.2.300.0130.00316.49
7.2.290.0100.00716.58
7.2.60.0100.00316.95
7.2.00.0040.01418.66
7.1.200.0090.00315.74
7.1.100.0060.00618.09
7.1.70.0000.00816.90
7.1.60.0140.01019.25
7.1.50.0270.01034.55
7.1.00.0100.07022.30
7.0.200.0000.00916.69
7.0.140.0000.07722.07
7.0.60.0070.07719.97
7.0.50.0070.05017.90
7.0.40.0100.06720.06
7.0.30.0270.05720.23
7.0.20.0170.04720.21
7.0.10.0130.04720.33
7.0.00.0130.05320.32
5.6.280.0000.07320.94
5.6.210.0100.03720.53
5.6.200.0070.06318.23
5.6.190.0100.06720.47
5.6.180.4070.04020.63
5.6.170.0330.06020.54
5.6.160.0070.08320.62
5.6.150.0070.07718.17
5.6.140.0030.04718.14
5.6.130.0070.08318.14
5.6.120.0100.06721.12
5.6.110.0000.08021.00
5.6.100.0100.08020.99
5.6.90.0130.07321.14
5.6.80.0100.07720.40
5.6.70.4400.03720.38
5.5.350.0100.07320.34
5.5.340.0030.04018.05
5.5.330.0030.08720.13
5.5.320.4070.04020.48
5.5.310.0270.07720.51
5.5.300.0030.07717.95
5.5.290.0030.04318.08
5.5.280.0070.08720.77
5.5.270.0070.08320.98
5.5.260.0000.09020.73
5.5.250.0030.08020.70
5.5.240.0170.06320.29
5.4.450.0170.07019.55
5.4.440.0230.07719.54
5.4.430.0270.07319.54
5.4.420.0330.07019.46
5.4.410.0230.05719.14
5.4.400.0330.06019.26
5.4.390.0330.07018.95
5.4.380.0330.06019.13
5.4.370.0230.05719.29
5.4.360.0300.07019.26
5.4.350.0270.07318.85
5.4.340.0300.06718.86
5.4.320.0230.07319.15
5.4.310.0270.04719.27
5.4.300.0270.05719.28
5.4.290.0230.05719.20
5.4.280.0200.05719.05
5.4.270.0230.05319.05
5.4.260.0230.05719.22
5.4.250.0300.03019.21
5.4.240.0230.06319.13
5.4.230.0270.06019.14
5.4.220.0270.05019.37
5.4.210.0100.05019.08
5.4.200.0170.04019.13
5.4.190.0200.07719.23
5.4.180.0200.06718.93
5.4.170.0130.04719.38
5.4.160.0270.07318.96
5.4.150.0300.06319.35
5.4.140.0270.07316.41
5.4.130.0230.06716.55
5.4.120.0370.06016.61
5.4.110.0230.07016.67
5.4.100.0300.02716.50
5.4.90.0230.04016.46
5.4.80.0270.02716.29
5.4.70.0300.06316.62
5.4.60.0270.06716.26
5.4.50.0230.07316.36
5.4.40.0270.06716.42
5.4.30.0230.07316.22
5.4.20.0300.06316.42
5.4.10.0270.06716.38
5.4.00.0330.05315.96
5.3.290.0300.06014.89
5.3.280.0200.07314.76
5.3.270.0230.06714.58
5.3.260.0270.03014.62
5.3.250.0270.05714.77
5.3.240.0170.04714.66
5.3.230.0230.07314.64
5.3.220.0270.06014.57
5.3.210.0200.05714.61
5.3.200.0170.04714.69
5.3.190.0230.03314.80
5.3.180.0170.04314.73
5.3.170.0170.03714.56
5.3.160.0270.06714.56
5.3.150.0200.07314.66
5.3.140.0270.07314.78
5.3.130.0200.07314.57
5.3.120.0300.07014.60
5.3.110.0400.06014.64
5.3.100.0200.04714.13
5.3.90.0200.05014.03
5.3.80.0230.07714.11
5.3.70.0270.07014.05
5.3.60.0230.07013.90
5.3.50.0200.06713.87
5.3.40.0230.05313.87
5.3.30.0130.05014.03
5.3.20.0200.08013.68
5.3.10.0370.06013.77
5.3.00.0230.04313.71
5.2.170.0200.04312.01
5.2.160.0270.05012.01
5.2.150.0170.03312.01
5.2.140.0230.03712.01
5.2.130.0170.06312.01
5.2.120.0200.05712.01
5.2.110.0200.05312.01
5.2.100.0200.04012.01
5.2.90.0200.06012.01
5.2.80.0200.06312.01
5.2.70.0230.05712.01
5.2.60.0130.06712.01
5.2.50.0300.03012.01
5.2.40.0230.05312.01
5.2.30.0200.03312.01
5.2.20.0170.03312.01
5.2.10.0170.06012.01
5.2.00.0200.05312.01
5.1.60.0200.05012.01
5.1.50.0170.05312.01
5.1.40.0200.03712.01
5.1.30.0200.05012.01
5.1.20.0130.04012.01
5.1.10.0170.05712.01
5.1.00.0170.05312.01
5.0.50.0070.05012.01
5.0.40.0100.04312.01
5.0.30.0030.04312.01
5.0.20.0030.02312.01
5.0.10.0170.03712.01
5.0.00.0070.06012.01
4.4.90.0130.01712.01
4.4.80.0130.03012.01
4.4.70.0100.03012.01
4.4.60.0100.03712.01
4.4.50.0100.02012.01
4.4.40.0070.04312.01
4.4.30.0100.02312.01
4.4.20.0130.03312.01
4.4.10.0100.02012.01
4.4.00.0100.03012.01
4.3.110.0070.03012.01
4.3.100.0130.03012.01
4.3.90.0100.01312.01
4.3.80.0130.04012.01
4.3.70.0070.02312.01
4.3.60.0070.02312.01
4.3.50.0100.02012.01
4.3.40.0130.04312.01
4.3.30.0030.03712.01
4.3.20.0030.03312.01
4.3.10.0100.03012.01
4.3.00.0100.02312.01

preferences:
53.75 ms | 400 KiB | 5 Q