3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combinations($arr) { $combinations = array_fill(0, count($arr)+1, array()); $combinations[0] = array(''); for ($i = 0, $n = count($arr); $i < $n; ++$i) { for ($l = $n-$i; $l > 0; --$l) { $combinations[$l][] = implode('', array_slice($arr, $i, $l)); } } return $combinations; } $arr = array('a', 'b', 'c', 'd', 'e', 'f'); var_dump(combinations($arr));
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { [0]=> array(1) { [0]=> string(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(2) "ab" [1]=> string(2) "bc" [2]=> string(2) "cd" [3]=> string(2) "de" [4]=> string(2) "ef" } [3]=> array(4) { [0]=> string(3) "abc" [1]=> string(3) "bcd" [2]=> string(3) "cde" [3]=> string(3) "def" } [4]=> array(3) { [0]=> string(4) "abcd" [1]=> string(4) "bcde" [2]=> string(4) "cdef" } [5]=> array(2) { [0]=> string(5) "abcde" [1]=> string(5) "bcdef" } [6]=> array(1) { [0]=> string(6) "abcdef" } }

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