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($count > 2) { $array_merg = get_combinations(array_slice($arrays, 1)); } else { $array_merg = $arrays[1]; } $tmp = array(); foreach($arrays[0] as $arele1) { foreach($array_merg as $arele2) { if(is_array($arele2)) { $tmp[] = array_unshift($arele2,$arele1); } else { $tmp[] = array($arele1,$arele2); } } } return $tmp; } var_dump(get_combinations($a));
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> int(3) [1]=> int(3) [2]=> int(3) [3]=> int(3) }

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.08 ms | 401 KiB | 8 Q