3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a[] = ["ID" => 101, "CODE" => 1]; $a[] = ["ID" => 105, "CODE" => 2]; $a[] = ["ID" => 109, "CODE" => 2]; $b[] = ["ID" => 105, "Amount" => 200]; $b[] = ["ID" => 101, "Amount" => 100]; $keys = array_merge(array_keys($a[0]), array_keys($b[0])); $template = array_combine($keys, array_fill(0, count($keys), null)); $a = array_column($a, null, "ID"); $b = array_column($b, null, "ID"); ksort($a); ksort($b); $res = array_map(function ($e1, $e2) use ($template){ if ($e1 && $e2) return array_merge($e1, $e2); $e = $e1 ? $e1 : $e2; return array_replace ($template, $e); }, $a, $b); print_r($res);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [ID] => 101 [CODE] => 1 [Amount] => 100 ) [1] => Array ( [ID] => 105 [CODE] => 2 [Amount] => 200 ) [2] => Array ( [ID] => 109 [CODE] => 2 [Amount] => ) )

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