3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ary1 = array( array( 'sn' => '123', 'name' => 'whatever', ), array( 'sn' => '234', 'name' => 'whatever', ), ); $ary2 = array( array( 'sn' => '123', 'gender' => 'male', ), array( 'sn' => '234', 'gender' => 'female', ), ); $res = []; foreach (array_merge($ary1, $ary2) as $a) { $res[$a['sn']] = array_merge($res[$a['sn']] ?? $a, $a); } var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [123]=> array(3) { ["sn"]=> string(3) "123" ["name"]=> string(8) "whatever" ["gender"]=> string(4) "male" } [234]=> array(3) { ["sn"]=> string(3) "234" ["name"]=> string(8) "whatever" ["gender"]=> string(6) "female" } }

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:
54.41 ms | 402 KiB | 8 Q