3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array('A' => array(1, 2), 'B' => array(3, 4), 'C' => array(5)); function get_combinations($arrays) { $result = array(array()); foreach ($arrays as $property => $property_values) { $tmp = array(); foreach ($result as $result_item) { foreach ($property_values as $property_value) { $tmp[] = array_merge($result_item, array($property => $property_value)); } } $result = $tmp; } return $result; } var_dump(get_combinations($a));
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(3) { ["A"]=> int(1) ["B"]=> int(3) ["C"]=> int(5) } [1]=> array(3) { ["A"]=> int(1) ["B"]=> int(4) ["C"]=> int(5) } [2]=> array(3) { ["A"]=> int(2) ["B"]=> int(3) ["C"]=> int(5) } [3]=> array(3) { ["A"]=> int(2) ["B"]=> int(4) ["C"]=> 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:
36.62 ms | 402 KiB | 8 Q