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('d', 'f', 'w', 's'); var_dump(combinations($arr));
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { [0]=> array(1) { [0]=> string(0) "" } [1]=> array(4) { [0]=> string(1) "d" [1]=> string(1) "f" [2]=> string(1) "w" [3]=> string(1) "s" } [2]=> array(3) { [0]=> string(2) "df" [1]=> string(2) "fw" [2]=> string(2) "ws" } [3]=> array(2) { [0]=> string(3) "dfw" [1]=> string(3) "fws" } [4]=> array(1) { [0]=> string(4) "dfws" } }

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:
40.73 ms | 402 KiB | 8 Q