3v4l.org

run code in 300+ PHP versions simultaneously
<?php $root = array( 1=>'cat1', 2=>'cat2', 3=>'cat3' ); $child_1 = array( 1=>'sub_cat1', 2=>'sub_cat2', 3=>'sub_cat3' ); $child_2 = array( 1=>'sub_sub_cat1', 2=>'sub_sub_cat2', 3=>'sub_sub_cat3' ); function getAllCombinationsArray($source_arrays = array(), $kd = array(), $vd = array()){ $return = array(); foreach(array_shift($source_arrays) as $ck => $cv) { $kdi = $kd + (array)$ck; $vdi = $vd + (array)$cv; if(!empty($source_arrays)) { $return += getAllCombinationsArray($source_arrays, $kdi, $vdi); } else { $return[implode('_', $kdi)] = implode(' -> ', $vdi); } } return $return; } print_r(getAllCombinationsArray(array($root, $child_1, $child_2)));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => cat1 [2] => cat2 [3] => cat3 )

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:
38.63 ms | 401 KiB | 8 Q