3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(array(1, 2), array(3, 4), array(5)); function get_combinations($arrays) { $result = array(array()); $count = count($arrays); if(is_array($arrays[0])) { $first_array = $arrays[0]; if($count > 2) { $array_merg = get_combinations(array_slice($arrays, 1)); } else { $array_merg = $arrays[1]; } $tmp = array(); foreach($first_array as $arele1) { foreach($array_merg as $arele2) { if(is_array($arele2)) { $tmp[] = array_merge(array($arele1),$arele2); } else { $tmp[] = array($arele1,$arele2); } } } return $tmp; } else { return $arrays; } } var_dump(get_combinations($a));
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(5) } [1]=> array(3) { [0]=> int(1) [1]=> int(4) [2]=> int(5) } [2]=> array(3) { [0]=> int(2) [1]=> int(3) [2]=> int(5) } [3]=> array(3) { [0]=> int(2) [1]=> int(4) [2]=> int(5) } }

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