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
Output for git.master, git.master_jit, rfc.property-hooks
array(0) { } array(15) { [0]=> string(2) "e1" [1]=> string(5) "e1-e2" [2]=> string(8) "e1-e2-e3" [3]=> string(11) "e1-e2-e3-e4" [4]=> string(8) "e1-e2-e4" [5]=> string(5) "e1-e3" [6]=> string(8) "e1-e3-e4" [7]=> string(5) "e1-e4" [8]=> string(2) "e2" [10]=> string(5) "e2-e3" [11]=> string(8) "e2-e3-e4" [12]=> string(5) "e2-e4" [13]=> string(2) "e3" [14]=> string(5) "e3-e4" [15]=> string(2) "e4" } array(15) { [0]=> string(2) "e1" [1]=> string(5) "e1-e2" [2]=> string(8) "e1-e2-e3" [3]=> string(11) "e1-e2-e3-e4" [4]=> string(8) "e1-e2-e4" [5]=> string(5) "e1-e3" [6]=> string(8) "e1-e3-e4" [7]=> string(5) "e1-e4" [8]=> string(2) "e2" [9]=> string(5) "e2-e3" [10]=> string(8) "e2-e3-e4" [11]=> string(5) "e2-e4" [12]=> string(2) "e3" [13]=> string(5) "e3-e4" [14]=> string(2) "e4" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
74.65 ms | 403 KiB | 8 Q