3v4l.org

run code in 300+ PHP versions simultaneously
<?php function comb($arr) { $combs = array_fill(0, count($arr)+1, array()); for ($i = 0, $n = count($arr); $i < $n; ++$i) { for ($j = $n-$i; $j > 0; --$j) { $combs[$j][] = implode(', ', array_slice($arr, $i, $j)); } } return $combs; } $arr = array('a', 'b', 'c', 'd', 'e', 'f'); var_dump(comb($arr));
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { [0]=> array(0) { } [1]=> array(6) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "e" [5]=> string(1) "f" } [2]=> array(5) { [0]=> string(4) "a, b" [1]=> string(4) "b, c" [2]=> string(4) "c, d" [3]=> string(4) "d, e" [4]=> string(4) "e, f" } [3]=> array(4) { [0]=> string(7) "a, b, c" [1]=> string(7) "b, c, d" [2]=> string(7) "c, d, e" [3]=> string(7) "d, e, f" } [4]=> array(3) { [0]=> string(10) "a, b, c, d" [1]=> string(10) "b, c, d, e" [2]=> string(10) "c, d, e, f" } [5]=> array(2) { [0]=> string(13) "a, b, c, d, e" [1]=> string(13) "b, c, d, e, f" } [6]=> array(1) { [0]=> string(16) "a, b, c, d, e, f" } }

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:
50.07 ms | 403 KiB | 8 Q