3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_1 = array("1a-dogs","2a-cats","3a-birds","4a-people"); $array_2 = array("4a-walking","2a-cats"); function splitArray ($arrayInput) { $arrayOutput = array(); foreach ($arrayInput as $element) { $tempArray = explode('-', $element); $arrayOutput[$tempArray[0]] = $tempArray[1]; } return $arrayOutput; } $arraySplit1 = splitArray($array_1); $arraySplit2 = splitArray($array_2); foreach ($arraySplit1 as $key1 => $value1) { if (array_key_exists($key1, $arraySplit2)) { $arraySplit1[$key1] = $arraySplit2[$key1]; } } print_r($arraySplit1);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1a] => dogs [2a] => cats [3a] => birds [4a] => walking )

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