3v4l.org

run code in 300+ PHP versions simultaneously
<?php function compound(array $arr) { $cache=array(); $rst=""; foreach($arr as $v) { if(empty($cache) || $v==end($cache)+1) { $cache[]=$v; } else { if(!empty($rst)) $rst.=","; if(count($cache)>2) $rst.=reset($cache)."-".end($cache); else $rst.=implode(",",$cache); $cache=array($v); } } if(!empty($rst)) $rst.=","; if(count($cache)>2) $rst.=reset($cache)."-".end($cache); else $rst.=implode(",",$cache); return $rst; } echo compound(array(1,2,3,5,6))."\n"; // gets "1-3,5,6" echo compound(array(1,3,4,5,6)); // gets "1,3-6"

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.0130.00316.50
8.3.50.0130.00716.52
8.3.40.0130.00318.79
8.3.30.0040.01118.84
8.3.20.0080.00018.77
8.3.10.0060.00318.90
8.3.00.0000.00919.50
8.2.170.0140.00722.96
8.2.160.0000.01518.96
8.2.150.0030.00624.18
8.2.140.0030.01024.66
8.2.130.0020.00526.16
8.2.120.0040.00420.51
8.2.110.0110.00022.25
8.2.100.0120.00018.21
8.2.90.0000.00819.34
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0000.00817.93
8.2.50.0000.00818.10
8.2.40.0040.00422.27
8.2.30.0040.00419.30
8.2.20.0040.00717.68
8.2.10.0000.00717.63
8.2.00.0080.00017.81
8.1.270.0000.00823.99
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0090.00022.09
8.1.230.0040.00817.64
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0040.00417.23
8.1.190.0000.00817.10
8.1.180.0090.00018.10
8.1.170.0040.00418.59
8.1.160.0040.00418.94
8.1.150.0040.00418.90
8.1.140.0080.00017.45
8.1.130.0070.00017.78
8.1.120.0040.00317.37
8.1.110.0000.00717.36
8.1.100.0050.00317.51
8.1.90.0000.00817.47
8.1.80.0020.00517.46
8.1.70.0000.00717.41
8.1.60.0030.00617.47
8.1.50.0040.00417.50
8.1.40.0020.00517.42
8.1.30.0060.00317.64
8.1.20.0000.00717.61
8.1.10.0040.00417.50
8.1.00.0040.00417.41
8.0.300.0040.00418.77
8.0.290.0000.00716.63
8.0.280.0030.00318.45
8.0.270.0000.00717.27
8.0.260.0000.00716.93
8.0.250.0000.00716.93
8.0.240.0050.00516.96
8.0.230.0000.00716.93
8.0.220.0000.00716.85
8.0.210.0040.00416.82
8.0.200.0000.00716.97
8.0.190.0070.00016.94
8.0.180.0030.00516.82
8.0.170.0030.00616.81
8.0.160.0000.00716.97
8.0.150.0030.00616.86
8.0.140.0030.00516.85
8.0.130.0030.00313.37
8.0.120.0120.00016.86
8.0.110.0080.00016.88
8.0.100.0000.00816.70
8.0.90.0040.00416.91
8.0.80.0080.00816.78
8.0.70.0040.00416.84
8.0.60.0040.00416.77
8.0.50.0000.00716.88
8.0.30.0100.01017.09
8.0.20.0160.00717.16
8.0.10.0070.00016.92
8.0.00.0100.01516.90
7.4.330.0000.00513.11
7.4.320.0000.00616.62
7.4.300.0030.00316.46
7.4.290.0000.00616.45
7.4.280.0090.00016.61
7.4.270.0050.00316.50
7.4.260.0030.00313.28
7.4.250.0040.00416.55
7.4.240.0000.00716.62
7.4.230.0030.00316.63
7.4.220.0110.00716.39
7.4.210.0130.00616.49
7.4.200.0030.00316.43
7.4.190.0000.00716.79
7.4.160.0090.00616.53
7.4.150.0110.00716.68
7.4.140.0150.00316.59
7.4.130.0090.00916.54
7.4.120.0070.01116.44
7.4.110.0030.01516.56
7.4.100.0090.00916.32
7.4.90.0150.00416.61
7.4.80.0070.01119.39
7.4.70.0100.00716.56
7.4.60.0120.00616.56
7.4.50.0120.00016.16
7.4.40.0030.01416.72
7.4.30.0090.00916.66
7.4.00.0030.01415.15
7.3.330.0000.00613.09
7.3.320.0000.00613.25
7.3.310.0040.00416.26
7.3.300.0000.00616.17
7.3.290.0030.01116.27
7.3.280.0080.01316.27
7.3.270.0140.00316.64
7.3.260.0130.00316.60
7.3.250.0070.01016.63
7.3.240.0100.00716.51
7.3.230.0100.00616.50
7.3.210.0140.00716.64
7.3.200.0100.00516.34
7.3.190.0070.01016.52
7.3.180.0110.00416.34
7.3.170.0100.00616.37
7.3.160.0090.00616.67
7.3.120.0070.01014.83
7.2.330.0080.00916.82
7.2.320.0000.02016.81
7.2.310.0070.01116.71
7.2.300.0080.00816.46
7.2.290.0070.01016.55
7.2.00.0000.01219.28
7.1.100.0080.00317.84
7.1.70.0040.00416.93
7.1.60.0000.02419.30
7.1.50.0040.01516.90
7.1.00.0000.07322.46
7.0.200.0030.00916.76
7.0.140.0000.07321.92
7.0.120.0070.06321.99
7.0.60.0270.04319.95
7.0.50.0070.08317.89
7.0.40.0030.05019.97
7.0.30.0230.04720.16
7.0.20.0400.06720.23
7.0.10.0000.04720.27
7.0.00.0100.08320.07
5.6.280.0070.07021.07
5.6.210.0000.09020.54
5.6.200.0030.04018.18
5.6.190.0030.04320.52
5.6.180.0230.04020.33
5.6.170.0200.06720.55
5.6.160.0030.04320.54
5.6.150.0030.03718.15
5.6.140.0030.08718.18
5.6.130.0030.08718.18
5.6.120.0000.06321.13
5.6.110.0200.06721.02
5.6.100.0130.08021.08
5.6.90.0000.04321.04
5.6.80.0070.08020.36
5.5.350.0000.07720.48
5.5.340.0070.08717.92
5.5.330.0130.07720.40
5.5.320.0230.04020.35
5.5.310.0330.04320.26
5.5.300.0070.05017.98
5.5.290.0030.04718.05
5.5.280.0100.07020.66
5.5.270.0130.08020.98
5.5.260.0130.07020.87
5.5.250.0100.08020.55
5.5.240.0030.03320.13
5.4.450.0100.03719.57
5.4.440.0130.06319.18
5.4.430.0100.06719.26
5.4.420.0070.07719.52
5.4.410.0070.06019.32
5.4.400.0100.07318.86
5.4.390.0100.03318.87
5.4.380.0030.03719.16
5.4.370.0070.03319.24
5.4.360.0000.04019.08
5.4.350.0070.03319.00
5.4.340.0000.04318.85
5.4.320.0000.04719.19
5.4.310.0100.03319.16
5.4.300.0000.04019.14
5.4.290.0030.03719.07
5.4.280.0070.03319.24
5.4.270.0030.03718.85
5.4.260.0130.03319.24
5.4.250.0000.04719.14
5.4.240.0000.04319.14
5.4.230.0070.03318.88
5.4.220.0030.03718.86
5.4.210.0030.04019.24
5.4.200.0070.03319.23
5.4.190.0030.03718.82
5.4.180.0070.03319.10
5.4.170.0100.03019.14
5.4.160.0030.03718.84
5.4.150.0000.04018.83
5.4.140.0070.03016.30
5.4.130.0100.06316.50
5.4.120.0030.07716.37
5.4.110.0030.03716.41
5.4.100.0070.04716.49
5.4.90.0000.04316.38
5.4.80.0070.07016.32
5.4.70.0030.04716.30
5.4.60.0030.07716.50
5.4.50.0070.04016.26
5.4.40.0070.03716.46
5.4.30.0070.04016.38
5.4.20.0070.04016.40
5.4.10.0030.04016.50
5.4.00.0030.03315.95
5.3.290.0070.03314.67
5.3.280.0030.04014.60
5.3.270.0030.04314.65
5.3.260.0070.03314.68
5.3.250.0070.03314.69
5.3.240.0000.03714.61
5.3.230.0130.06714.61
5.3.220.0030.04314.73
5.3.210.0130.06314.57
5.3.200.0000.04314.74
5.3.190.0070.06314.59
5.3.180.0070.07314.61
5.3.170.0100.04014.64
5.3.160.0030.04014.64
5.3.150.0030.04714.61
5.3.140.0000.06714.59
5.3.130.0070.04314.61
5.3.120.0070.03314.72
5.3.110.0070.03714.61
5.3.100.0030.04714.05
5.3.90.0000.04314.03
5.3.80.0030.03714.04
5.3.70.0070.03714.19
5.3.60.0070.03313.93
5.3.50.0000.04014.02
5.3.40.0030.08013.97
5.3.30.0100.07314.08
5.3.20.0070.06713.70
5.3.10.0070.07013.68
5.3.00.0030.08013.65
5.2.170.0100.05711.11
5.2.160.0030.04011.08
5.2.150.0030.06311.12
5.2.140.0070.03711.21
5.2.130.0030.06011.17
5.2.120.0070.05311.19
5.2.110.0030.04011.16
5.2.100.0100.02311.11
5.2.90.0000.06711.12
5.2.80.0030.04011.11
5.2.70.0070.02711.16
5.2.60.0000.03311.06
5.2.50.0100.03310.95
5.2.40.0100.03011.03
5.2.30.0070.06011.13
5.2.20.0030.05311.00
5.2.10.0100.06310.87
5.2.00.0000.06310.72
5.1.60.0030.03310.02
5.1.50.0070.0279.99
5.1.40.0070.0239.97
5.1.30.0000.03310.32
5.1.20.0030.03310.36
5.1.10.0130.04010.14
5.1.00.0100.03710.05
5.0.50.0000.0478.70
5.0.40.0030.0178.39
5.0.30.0000.0408.36
5.0.20.0030.0278.27
5.0.10.0000.0508.07
5.0.00.0030.0308.21
4.4.90.0000.0377.71
4.4.80.0000.0177.71
4.4.70.0100.0237.71
4.4.60.0000.0377.71
4.4.50.0030.0277.71
4.4.40.0030.0277.71
4.4.30.0000.0177.71
4.4.20.0070.0337.71
4.4.10.0000.0407.71
4.4.00.0030.0437.71
4.3.110.0070.0177.71
4.3.100.0030.0237.71
4.3.90.0030.0237.71
4.3.80.0000.0577.71
4.3.70.0000.0377.71
4.3.60.0030.0337.71
4.3.50.0030.0177.71
4.3.40.0070.0507.71
4.3.30.0000.0337.71
4.3.20.0000.0237.71
4.3.10.0070.0237.71
4.3.00.0000.0377.71

preferences:
59.46 ms | 400 KiB | 5 Q