3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [0, 1, 2, 3, 4, 5, 6, 7]; $index = 3; // Result: 1, 2, 3, 4, 5. *example 1 echo pages($a, $index) . "\n"; $index = 0; // Result: 0, 1, 2, 3, 4. *example 2 echo pages($a, $index) . "\n"; $index = 7; // Result: 3, 4, 5, 6, 7. *example 3 echo pages($a, $index) . "\n"; $index = 6; // Result: 3, 4, 5, 6, 7. *example 4 echo pages($a, $index) . "\n"; function pages($a, $index){ if($index >= count($a)-2){ $start = count($a)-5; }elseif($index <=2){ $start = 0; }else{ $start = $index-2; } return implode(", ", array_slice($a, $start, 5)); }

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.4.120.0130.00720.56
8.4.110.0100.00422.58
8.4.100.0070.00817.57
8.4.90.0090.00820.55
8.4.80.0050.00518.83
8.4.70.0020.00618.87
8.4.60.0140.00620.72
8.4.50.0110.01118.33
8.4.40.0150.00419.12
8.4.30.0100.01019.48
8.4.20.0070.01320.32
8.4.10.0140.00718.88
8.3.250.0130.00518.91
8.3.240.0110.00917.07
8.3.230.0110.00716.50
8.3.220.0070.00518.88
8.3.210.0090.00716.77
8.3.200.0050.00416.40
8.3.190.0050.00917.23
8.3.180.0080.01118.79
8.3.170.0070.00317.12
8.3.160.0150.00318.18
8.3.150.0040.00416.53
8.3.140.0070.00016.57
8.3.130.0030.01716.60
8.3.120.0000.00919.00
8.3.110.0030.00620.94
8.3.100.0090.00624.06
8.3.90.0080.00026.77
8.3.80.0040.00416.63
8.3.70.0070.01116.58
8.3.60.0090.00918.00
8.3.50.0090.01018.07
8.3.40.0070.00718.71
8.3.30.0110.00418.75
8.3.20.0040.00423.70
8.3.10.0000.00823.56
8.3.00.0000.00721.90
8.2.290.0120.00617.18
8.2.280.0130.00718.39
8.2.270.0000.00816.62
8.2.260.0150.00416.88
8.2.250.0080.00018.49
8.2.240.0090.00018.82
8.2.230.0050.00522.58
8.2.220.0120.00637.54
8.2.210.0090.00926.77
8.2.200.0040.00716.63
8.2.190.0120.00316.63
8.2.180.0110.00725.92
8.2.170.0090.00918.91
8.2.160.0030.01022.96
8.2.150.0000.00725.66
8.2.140.0020.00524.66
8.2.130.0050.00326.16
8.2.120.0080.00019.95
8.2.110.0040.00421.11
8.2.100.0070.00317.84
8.2.90.0040.00419.52
8.2.80.0060.00317.97
8.2.70.0060.00317.93
8.2.60.0040.00418.08
8.2.50.0000.00818.10
8.2.40.0040.00422.32
8.2.30.0070.00019.12
8.2.20.0040.00418.13
8.2.10.0000.00718.04
8.2.00.0060.00319.28
8.1.330.0120.00722.19
8.1.320.0150.00818.36
8.1.310.0070.00016.75
8.1.300.0080.00016.28
8.1.290.0030.00618.88
8.1.280.0110.00425.92
8.1.270.0040.00424.66
8.1.260.0070.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00322.20
8.1.230.0030.00920.88
8.1.220.0030.00617.74
8.1.210.0050.00319.04
8.1.200.0000.00917.35
8.1.190.0050.00317.23
8.1.180.0080.00018.10
8.1.170.0040.00418.50
8.1.160.0000.00718.95
8.1.150.0070.00018.82
8.1.140.0070.00022.14
8.1.130.0040.00420.18
8.1.120.0030.00317.36
8.1.110.0000.00717.41
8.1.100.0040.00417.47
8.1.90.0050.00317.41
8.1.80.0000.00817.43
8.1.70.0030.00317.49
8.1.60.0080.00017.57
8.1.50.0040.00417.55
8.1.40.0050.00217.50
8.1.30.0040.00417.62
8.1.20.0070.00317.56
8.1.10.0080.00017.50
8.1.00.0000.00817.37
8.0.300.0070.00020.07
8.0.290.0030.00616.63
8.0.280.0000.00718.45
8.0.270.0030.00317.14
8.0.260.0060.00018.44
8.0.250.0070.00016.94
8.0.240.0040.00416.94
8.0.230.0070.00016.83
8.0.220.0030.00616.89
8.0.210.0030.00316.78
8.0.200.0070.00016.99
8.0.190.0040.00416.82
8.0.180.0050.00316.90
8.0.170.0030.00616.82
8.0.160.0080.00016.90
8.0.150.0030.00316.83
8.0.140.0000.00816.84
8.0.130.0030.00313.34
8.0.120.0000.00716.76
8.0.110.0040.00416.79
8.0.100.0000.00716.76
8.0.90.0040.00416.77
8.0.80.0060.00916.95
8.0.70.0040.00416.98
8.0.60.0050.00216.99
8.0.50.0070.00016.71
8.0.30.0140.00617.18
8.0.20.0140.01117.40
8.0.10.0050.00316.89
8.0.00.0090.00916.88
7.4.330.0020.00216.67
7.4.320.0030.00316.40
7.4.300.0040.00416.50
7.4.290.0030.00316.51
7.4.280.0000.00716.52
7.4.270.0030.00516.50
7.4.260.0070.00016.59
7.4.250.0030.00316.56
7.4.240.0000.00816.44
7.4.230.0000.00716.52
7.4.220.0020.00516.40
7.4.210.0100.00816.60
7.4.200.0070.00016.63
7.4.160.0090.00716.53
7.4.140.0100.01017.86
7.4.130.0030.01316.41
7.4.120.0110.00916.51
7.4.110.0160.00916.52
7.4.100.0110.00916.55
7.4.90.0090.00916.55
7.4.80.0080.01119.39
7.4.70.0030.01416.52
7.4.60.0110.00716.55
7.4.50.0130.00316.38
7.4.40.0080.00816.48
7.4.00.0040.01214.90
7.3.330.0020.00213.28
7.3.320.0030.00313.38
7.3.310.0070.00016.30
7.3.300.0060.00016.14
7.3.290.0000.00716.27
7.3.280.0070.01216.32
7.3.260.0090.01116.49
7.3.240.0070.01116.48
7.3.230.0160.00016.57
7.3.210.0040.01316.42
7.3.200.0100.01116.36
7.3.190.0000.01816.51
7.3.180.0120.00416.52
7.3.170.0030.02016.39
7.3.160.0120.00616.37
7.3.120.0130.00515.04
7.3.110.0080.01014.78
7.3.100.0100.00514.80
7.3.90.0070.00814.70
7.3.80.0110.00514.68
7.3.70.0060.00614.79
7.3.60.0070.00714.77
7.3.50.0070.00514.72
7.3.40.0050.00914.81
7.3.30.0040.00614.90
7.3.20.0110.00316.56
7.3.10.0090.00516.74
7.3.00.0080.00716.47
7.2.330.0000.01716.59
7.2.320.0090.00616.75
7.2.310.0190.00816.39
7.2.300.0110.00916.57
7.2.290.0140.00316.72
7.2.250.0030.01515.13
7.2.240.0080.01315.11
7.2.230.0040.01014.99
7.2.220.0080.00514.82
7.2.210.0030.01415.10
7.2.200.0040.01114.99
7.2.190.0100.00515.11
7.2.180.0070.00714.89
7.2.170.0080.00815.01
7.2.120.0000.01216.77
7.2.110.0040.01216.31
7.2.100.0060.00616.66
7.2.90.0030.00916.72
7.2.80.0020.01416.58
7.2.70.0080.00916.95
7.2.60.0090.00916.77
7.2.50.0130.00016.80
7.2.40.0070.01016.75
7.2.30.0080.00817.09
7.2.20.0130.00316.88
7.2.10.0000.01316.72
7.2.00.0060.00917.00
7.1.330.0050.00715.61
7.1.320.0060.00415.83
7.1.310.0070.00715.76
7.1.300.0070.00415.58
7.1.290.0050.00815.75
7.1.280.0020.01415.79
7.1.270.0050.00715.79
7.1.260.0070.00615.82
5.6.380.0040.00714.21

preferences:
193.66 ms | 403 KiB | 5 Q