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 getClosest($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.60.0140.00718.43
8.3.50.0110.00722.05
8.3.40.0040.01118.75
8.3.30.0070.00719.18
8.3.20.0070.00020.47
8.3.10.0070.00021.85
8.3.00.0050.00317.93
8.2.180.0130.00616.63
8.2.170.0060.00922.96
8.2.160.0100.00320.52
8.2.150.0110.00424.18
8.2.140.0050.00324.66
8.2.130.0140.00426.16
8.2.120.0050.00321.05
8.2.110.0060.00322.40
8.2.100.0060.00618.03
8.2.90.0040.00419.37
8.2.80.0000.00817.97
8.2.70.0090.00017.63
8.2.60.0000.00818.05
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0070.00318.18
8.2.20.0000.00817.85
8.2.10.0040.00418.25
8.2.00.0050.00317.83
8.1.280.0040.01125.92
8.1.270.0090.00024.09
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00323.83
8.1.230.0040.00819.13
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0100.00317.48
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0030.00518.64
8.1.160.0000.00822.16
8.1.150.0000.00718.88
8.1.140.0000.00717.50
8.1.130.0000.00717.82
8.1.120.0000.00717.54
8.1.110.0080.00017.54
8.1.100.0050.00317.52
8.1.90.0040.00417.39
8.1.80.0050.00217.41
8.1.70.0040.00417.39
8.1.60.0000.00817.64
8.1.50.0030.00517.55
8.1.40.0080.00017.55
8.1.30.0040.00417.72
8.1.20.0030.00517.75
8.1.10.0040.00417.59
8.1.00.0000.00817.64
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.57
8.0.270.0030.00317.28
8.0.260.0050.00317.33
8.0.250.0000.00717.06
8.0.240.0070.00017.04
8.0.230.0050.00316.96
8.0.220.0030.00316.94
8.0.210.0050.00317.03
8.0.200.0040.00416.95
8.0.190.0000.00716.99
8.0.180.0000.00716.94
8.0.170.0030.00617.08
8.0.160.0040.00416.89
8.0.150.0030.00517.04
8.0.140.0070.00417.00
8.0.130.0030.00313.52
8.0.120.0060.00317.03
8.0.110.0000.00717.08
8.0.100.0050.00217.13
8.0.90.0070.00016.85
8.0.80.0100.00616.91
8.0.70.0070.00016.91
8.0.60.0070.00017.03
8.0.50.0080.00016.93
8.0.30.0160.00817.33
8.0.20.0080.01117.40
8.0.10.0000.00716.95
8.0.00.0080.00916.80
7.4.330.0030.00315.15
7.4.320.0040.00416.69
7.4.300.0070.00016.67
7.4.290.0040.00416.46
7.4.280.0050.00316.47
7.4.270.0000.00716.57
7.4.260.0020.00916.64
7.4.250.0040.00416.45
7.4.240.0040.00416.57
7.4.230.0000.00716.73
7.4.220.0070.01116.60
7.4.210.0070.01316.60
7.4.200.0040.00416.60
7.4.160.0130.00316.61
7.4.150.0070.01117.40
7.4.140.0150.00817.86
7.4.130.0080.00916.61
7.4.120.0120.00916.74
7.4.110.0130.00316.63
7.4.100.0130.00616.75
7.4.90.0120.00616.58
7.4.80.0070.01319.39
7.4.70.0070.01116.55
7.4.60.0090.00916.53
7.4.50.0030.00516.64
7.4.40.0140.00316.71
7.4.30.0030.01216.53
7.4.00.0000.01815.12
7.3.330.0000.00713.45
7.3.320.0050.00013.49
7.3.310.0000.00716.59
7.3.300.0070.00016.38
7.3.290.0040.01416.46
7.3.280.0070.01016.51
7.3.270.0100.00717.40
7.3.260.0070.01016.57
7.3.250.0100.01016.57
7.3.240.0070.01016.46
7.3.230.0070.01016.48
7.3.210.0060.01116.66
7.3.200.0110.00719.39
7.3.190.0060.01316.39
7.3.180.0050.01016.50
7.3.170.0090.00916.71
7.3.160.0090.00616.51
7.3.120.0060.00914.98
7.2.330.0140.00416.93
7.2.320.0130.00416.75
7.2.310.0060.01216.74
7.2.300.0100.00616.82
7.2.290.0100.01016.79
7.2.60.0070.01016.80
7.2.00.0050.00518.80
7.1.200.0040.00815.91
7.1.100.0030.00818.11
7.1.70.0040.00416.90
7.1.60.0060.01619.25
7.1.50.0200.01034.84
7.1.00.0030.07022.36
7.0.200.0090.00016.71
7.0.140.0000.07022.00
7.0.60.0100.08020.05
7.0.50.0030.04717.86
7.0.40.0070.08020.30
7.0.30.0470.04020.07
7.0.20.0200.07320.20
7.0.10.0100.03720.26
7.0.00.0100.05320.33
5.6.280.0000.07720.82
5.6.210.0070.05320.77
5.6.200.0100.04718.15
5.6.190.0030.06020.57
5.6.180.0170.06720.77
5.6.170.0230.07320.61
5.6.160.0030.04720.62
5.6.150.0000.08718.15
5.6.140.0100.06718.17
5.6.130.0100.05018.21
5.6.120.0100.06720.93
5.6.110.0100.08720.98
5.6.100.0130.07021.12
5.6.90.0070.03720.98
5.6.80.0030.05020.55
5.5.350.0030.05720.41
5.5.340.0030.04718.01
5.5.330.0130.03320.19
5.5.320.3970.04720.34
5.5.310.0230.05020.32
5.5.300.0000.04018.04
5.5.290.0030.04017.95
5.5.280.0070.05320.80
5.5.270.0230.05720.97
5.5.260.0070.08320.96
5.5.250.0100.08320.69
5.5.240.0100.04020.38
5.4.450.0230.04719.40
5.4.440.0230.04319.55
5.4.430.0070.06019.51
5.4.420.0070.05719.57
5.4.410.0200.04718.81
5.4.400.0100.08018.53
5.4.390.0070.05318.52
5.4.380.0200.05318.70
5.4.370.0170.04718.84
5.4.360.0100.04318.79
5.4.350.0040.05312.03
5.4.340.0170.07012.03
5.4.320.0050.04012.52
5.4.310.0060.04012.52
5.4.300.0100.03812.51
5.4.290.0020.04312.51
5.4.280.0070.03512.41
5.4.270.0070.03512.41
5.4.260.0050.03912.41
5.4.250.0090.03512.41
5.4.240.0060.03612.41
5.4.230.0040.04012.40
5.4.220.0030.03912.41
5.4.210.0100.03212.41
5.4.200.0090.03512.40
5.4.190.0080.05212.40
5.4.180.0070.04312.40
5.4.170.0060.03912.40
5.4.160.0060.03712.40
5.4.150.0100.03212.39
5.4.140.0070.03612.08
5.4.130.0080.03512.07
5.4.120.0090.03212.02
5.4.110.0060.03612.02
5.4.100.0060.04112.02
5.4.90.0070.03612.02
5.4.80.0100.04612.02
5.4.70.0050.03612.01
5.4.60.0100.03812.02
5.4.50.0050.03612.02
5.4.40.0050.03812.00
5.4.30.0050.04012.00
5.4.20.0060.03612.00
5.4.10.0090.03212.00
5.4.00.0080.03511.49
5.3.290.0070.04412.80
5.3.280.0050.05212.71
5.3.270.0040.04112.72
5.3.260.0070.04212.71
5.3.250.0070.04012.71
5.3.240.0080.04012.72
5.3.230.0050.04512.71
5.3.220.0070.04712.68
5.3.210.0110.04612.68
5.3.200.0070.03612.68
5.3.190.0110.03612.68
5.3.180.0050.04012.67
5.3.170.0080.03812.67
5.3.160.0060.03812.68
5.3.150.0050.04312.67
5.3.140.0090.05012.66
5.3.130.0110.04912.66
5.3.120.0050.05012.66
5.3.110.0030.04512.66
5.3.100.0050.04412.13
5.3.90.0080.03912.12
5.3.80.0050.04312.11
5.3.70.0060.04112.11
5.3.60.0060.03612.09
5.3.50.0040.03912.04
5.3.40.0070.03612.04
5.3.30.0070.03512.00
5.3.20.0100.03211.78
5.3.10.0060.03711.74
5.3.00.0030.04011.72
5.2.170.0060.0309.25
5.2.160.0050.0319.24
5.2.150.0070.0309.25
5.2.140.0040.0329.25
5.2.130.0050.0309.20
5.2.120.0040.0319.21
5.2.110.0070.0279.21
5.2.100.0090.0339.21
5.2.90.0040.0319.21
5.2.80.0040.0329.21
5.2.70.0060.0299.21
5.2.60.0080.0289.16
5.2.50.0090.0389.13
5.2.40.0050.0379.10
5.2.30.0050.0319.08
5.2.20.0040.0309.07
5.2.10.0060.0278.99
5.2.00.0020.0328.86
5.1.60.0060.0228.13
5.1.50.0080.0218.13
5.1.40.0050.0248.11
5.1.30.0040.0268.46
5.1.20.0040.0268.48
5.1.10.0030.0288.20
5.1.00.0070.0258.21
5.0.50.0030.0216.65
5.0.40.0040.0196.51
5.0.30.0050.0366.32
5.0.20.0050.0176.29
5.0.10.0070.0176.27
5.0.00.0050.0306.26
4.4.90.0030.0164.78
4.4.80.0020.0164.76
4.4.70.0040.0164.75
4.4.60.0010.0194.76
4.4.50.0030.0154.77
4.4.40.0060.0254.70
4.4.30.0020.0204.76
4.4.20.0060.0144.84
4.4.10.0040.0224.85
4.4.00.0030.0264.76
4.3.110.0040.0154.67
4.3.100.0020.0174.66
4.3.90.0020.0164.63
4.3.80.0050.0244.58
4.3.70.0060.0204.63
4.3.60.0050.0224.63
4.3.50.0050.0144.63
4.3.40.0040.0244.54
4.3.30.0040.0143.31
4.3.20.0020.0163.29
4.3.10.0020.0163.25
4.3.00.0030.01315.26

preferences:
44.02 ms | 401 KiB | 5 Q