3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPairs($array) { $n = count($array); $finalArray = []; $i = 0; foreach ($array as $a) { for ($x = $n-1; $i < $x; $x--) { $key1 = array_keys($array)[$i]; $key2 = array_keys($array)[$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:
70.26 ms | 401 KiB | 8 Q