3v4l.org

run code in 300+ 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.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.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.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:
17.71 ms | 401 KiB | 5 Q