3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combs($letters) { $result = array(); $lettersCount = count($letters); for ($i = 0; $i < $lettersCount; ++$i) { for ($j = $lettersCount - $i; $j > 0; --$j) { $result[$j][] = implode(', ', array_slice($letters, $i, $j)); } } return $result; } $arr = array('a', 'b', 'c', 'd', 'e', 'f'); print_r(combs($arr));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [6] => Array ( [0] => a, b, c, d, e, f ) [5] => Array ( [0] => a, b, c, d, e [1] => b, c, d, e, f ) [4] => Array ( [0] => a, b, c, d [1] => b, c, d, e [2] => c, d, e, f ) [3] => Array ( [0] => a, b, c [1] => b, c, d [2] => c, d, e [3] => d, e, f ) [2] => Array ( [0] => a, b [1] => b, c [2] => c, d [3] => d, e [4] => e, f ) [1] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => 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:
49.03 ms | 403 KiB | 8 Q