3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeArray(array $arr1, array $arr2) { $keysStats = array(); foreach ($arr1 as $index => $key) { $keysStats[$key] = array( 'arr1' => $index, 'arr2' => null ); } foreach ($arr2 as $index => $key) { if (!array_key_exists($key, $keysStats)) { $keysStats[$key] = array( 'arr1' => null, 'arr2' => $index ); } else { $keysStats[$key]['arr2'] = $index; } } $allKeys = array_keys($keysStats); sort($allKeys); $merged = array(); foreach ($allKeys as $key) { if (is_null($keysStats[$key]['arr2'])) { $merged[] = null; } else { $merged[] = $arr2[$keysStats[$key]['arr2']]; } } return $merged; } var_dump(mergeArray( array( 'a', 'b', 'c', 'd', 'e', 'f', 'g' ), array( 'a', 'b', 'q', 'z' ) ));
Output for git.master, git.master_jit, rfc.property-hooks
array(9) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> string(1) "q" [8]=> string(1) "z" }

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.18 ms | 401 KiB | 8 Q