3v4l.org

run code in 500+ PHP versions simultaneously
<?php $in = array('e1','e2','e3','e4'); //$new =[]; $count = count($in); Foreach($in as $key => $val){ $new[] = $val; // add first value // loop through in to greate the long incrementing string For($i=$key; $i<=$count-$key;$i++){ if($key != 0){ $new[] = implode("-",array_slice($in,$key,$i)); }else{ if($i - $key>1) $new[] = implode("-",array_slice($in,$key,$i)); } } // all but second to last except if iteration has come to far if($count-2-$key >1) $new[] = Implode("-",Array_slice($in,$key,$count-2)). "-". $in[$count-1]; // $key (skip one) next one. except if iteration has come to far If($count-2-$key >1) $new[] = $in[$key] . "-" . $in[$key+2]; // $key (skip one) rest of array except if iteration has come to far if($count-2-$key > 1) $new[] = $in[$key] ."-". Implode("-",Array_slice($in,$key+2)); // $key and last item, except if iteration has come to far if($count-1 - $key >1) $new[] = $in[$key] ."-". $in[$count-1]; } $new = array_unique($new); // remove any duplicates that may have been created $result = array( 0 => 'e1', 1 => 'e1-e2', 2 => 'e1-e2-e3', 3 => 'e1-e2-e3-e4', 4 => 'e1-e2-e4', 5 => 'e1-e3', 6 => 'e1-e3-e4', 7 => 'e1-e4', 8 => 'e2', 9 => 'e2-e3', 10 => 'e2-e3-e4', 11 => 'e2-e4', 12 => 'e3', 13 => 'e3-e4', 14 => 'e4' ); var_dump(array_diff($new,$result)); // compare arrays if there is any difference Var_dump($new, $result); // output them

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.5.60.0110.00616.63
8.5.50.0070.01116.89
8.5.30.0140.00817.57
8.5.20.0140.00519.45
8.5.10.0070.01216.88
8.5.00.0130.00919.73
8.4.210.0110.00919.66
8.4.180.0150.00723.93
8.4.170.0110.01220.56
8.4.160.0130.00824.02
8.4.150.0080.00516.96
8.4.140.0120.01017.36
8.4.130.0130.00719.05
8.4.120.0050.00524.16
8.4.110.0080.01118.96
8.4.100.0050.00417.77
8.4.90.0120.00918.60
8.4.80.0020.00719.37
8.4.70.0140.00618.06
8.4.60.0070.00219.08
8.4.50.0150.00520.46
8.4.40.0100.01020.79
8.4.30.0110.00717.52
8.4.20.0100.00719.46
8.4.10.0040.01219.48
8.3.300.0160.00520.75
8.3.290.0100.01120.71
8.3.280.0110.00918.47
8.3.270.0140.00616.35
8.3.260.0100.01016.69
8.3.250.0110.00518.79
8.3.240.0090.01116.72
8.3.230.0040.00516.72
8.3.220.0110.00717.10
8.3.210.0080.00916.66
8.3.200.0040.00516.56
8.3.190.0040.00517.25
8.3.180.0090.01016.58
8.3.170.0180.00017.30
8.3.160.0040.01520.50
8.3.150.0120.00817.23
8.3.140.0130.00616.80
8.3.130.0060.00318.44
8.3.120.0080.01119.10
8.3.110.0110.00416.75
8.3.100.0090.00024.06
8.3.90.0040.01126.77
8.3.80.0040.00718.30
8.3.70.0120.00616.63
8.3.60.0160.00316.88
8.3.50.0120.00518.35
8.3.40.0130.00618.84
8.3.30.0070.00718.84
8.3.20.0040.00420.21
8.3.10.0030.00621.65
8.3.00.0080.00021.69
8.2.300.0100.00922.13
8.2.290.0110.00920.51
8.2.280.0090.01018.11
8.2.270.0070.01117.41
8.2.260.0030.00618.89
8.2.250.0040.00418.95
8.2.240.0060.01318.97
8.2.230.0080.00320.94
8.2.220.0100.00037.54
8.2.210.0100.01026.77
8.2.200.0000.00918.17
8.2.190.0000.01516.63
8.2.180.0110.00718.29
8.2.170.0000.01522.96
8.2.160.0070.00722.14
8.2.150.0060.00324.18
8.2.140.0000.00824.66
8.2.130.0000.00822.24
8.2.120.0080.00026.35
8.2.110.0040.00422.15
8.2.100.0000.01217.91
8.2.90.0030.00717.98
8.2.80.0060.00319.89
8.2.70.0040.00417.75
8.2.60.0030.00517.63
8.2.50.0080.00017.55
8.2.40.0080.00022.30
8.2.30.0000.00719.43
8.2.20.0040.00418.23
8.2.10.0000.00718.17
8.2.00.0080.00018.21
8.1.340.0130.00919.92
8.1.330.0140.00522.25
8.1.320.0060.01016.09
8.1.310.0080.00016.84
8.1.300.0080.01118.62
8.1.290.0060.00330.84
8.1.280.0110.00325.92
8.1.270.0000.00822.08
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00320.72
8.1.230.0040.00720.88
8.1.220.0000.00817.74
8.1.210.0060.00318.77
8.1.200.0000.00817.22
8.1.190.0040.00417.23
8.1.180.0000.01118.10
8.1.170.0090.00018.52
8.1.160.0050.00219.04
8.1.150.0040.00420.17
8.1.140.0040.00419.16
8.1.130.0080.00017.41
8.1.120.0000.00717.40
8.1.110.0040.00417.40
8.1.100.0050.00317.52
8.1.90.0100.00017.38
8.1.80.0050.00317.45
8.1.70.0070.00017.54
8.1.60.0080.00317.52
8.1.50.0030.00517.46
8.1.40.0030.00517.61
8.1.30.0000.00717.71
8.1.20.0090.00017.61
8.1.10.0040.00417.45
8.1.00.0050.00317.52
8.0.300.0080.00020.01
8.0.290.0000.00817.00
8.0.280.0030.00318.48
8.0.270.0000.00717.18
8.0.260.0040.00418.49
8.0.250.0100.00016.98
8.0.240.0030.00717.04
8.0.230.0020.00517.02
8.0.220.0000.00716.84
8.0.210.0040.00416.92
8.0.200.0030.00317.01
8.0.190.0000.01117.00
8.0.180.0000.00717.02
8.0.170.0000.00717.00
8.0.160.0040.00417.01
8.0.150.0000.00716.83
8.0.140.0070.00016.88
8.0.130.0000.00613.30
8.0.120.0000.00816.89
8.0.110.0050.00316.76
8.0.100.0050.00216.89
8.0.90.0000.00717.00
8.0.80.0100.01016.91
8.0.70.0040.00416.98
8.0.60.0020.00516.79
8.0.50.0040.00416.80
8.0.30.0100.01117.10
8.0.20.0120.01017.40
8.0.10.0030.00517.10
8.0.00.0120.00916.65
7.4.330.0020.00215.55
7.4.320.0000.00616.56
7.4.300.0000.00616.46
7.4.290.0040.00416.39
7.4.280.0040.00416.66
7.4.270.0030.00316.45
7.4.260.0070.00016.64
7.4.250.0090.00016.60
7.4.240.0040.00416.48
7.4.230.0030.00316.64
7.4.220.0120.01216.40
7.4.210.0060.01516.72
7.4.200.0040.00416.75
7.4.160.0090.01016.62
7.4.150.0100.00917.40
7.4.140.0110.01117.86
7.4.130.0240.00016.45
7.4.120.0110.01216.57
7.4.110.0110.00716.35
7.4.100.0120.01216.59
7.4.90.0150.00416.50
7.4.80.0040.01419.39
7.4.70.0170.00716.56
7.4.60.0030.01316.59
7.4.50.0030.01316.69
7.4.40.0090.00916.60
7.4.30.0100.00716.48
7.4.00.0000.01415.18
7.3.330.0000.00613.18
7.3.320.0000.00513.15
7.3.310.0030.00316.44
7.3.300.0070.00016.30
7.3.290.0080.00816.40
7.3.280.0070.00816.31
7.3.270.0160.01017.40
7.3.260.0090.01016.36
7.3.250.0120.00716.47
7.3.240.0100.01216.52
7.3.230.0130.01016.38
7.3.210.0030.02016.34
7.3.200.0040.01516.24
7.3.190.0050.01016.63
7.3.180.0100.00716.48
7.3.170.0140.00616.38
7.3.160.0060.01316.64
7.2.330.0100.00716.54
7.2.320.0040.01516.73
7.2.310.0070.01016.70
7.2.300.0060.01116.78
7.2.290.0150.00916.91
7.2.60.0070.00016.77
7.2.00.0110.00719.24
7.1.200.0090.00615.46
7.1.120.0090.00918.63
7.1.110.0070.00718.00
7.1.100.0030.00918.09
7.1.90.0040.00918.17
7.1.80.0090.01218.23
7.1.70.0030.01017.19
7.1.60.0200.00735.23
7.1.50.0140.01134.64
7.1.40.0220.00434.45
7.1.30.0250.00834.53
7.1.20.0100.01634.60
7.1.10.0090.00616.51
7.1.00.0000.01616.52

preferences:
49.48 ms | 1596 KiB | 5 Q