3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPairs($array) { $n = count($array); $keys = array_keys($array); $finalArray = []; $i = 0; foreach ($array as $a) { for ($x = $n-1; $i < $x; $x--) { $key1 = $keys[$i]; $key2 = $keys[$x]; $finalArray[$key1.$key2] = [$array[$key1], $array[$key2]]; } $i++; } return $finalArray; } $arr1 = 'arr1'; $arr2 = 'arr2'; $arr3 = 'arr3'; $merged = [ 'a'=> $arr1, 'b'=> $arr2, 'c'=> $arr3 ]; $pairs = getPairs($merged); print_r($pairs);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [ac] => Array ( [0] => arr1 [1] => arr3 ) [ab] => Array ( [0] => arr1 [1] => arr2 ) [bc] => Array ( [0] => arr2 [1] => arr3 ) )

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:
63.2 ms | 406 KiB | 5 Q