3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ [ 'id' => 1, 'name' => 'John', 'email' => 'j@mail.com' ], [ 'id' => 2, 'name' => 'Jane', 'email' => 'jane@mail.com' ] ]; $arr2 = [ [ 'id' => 1, 'email' => 'john@yahoo.com' ], [ 'id' => 2, 'email' => 'jane@yahoo.com' ], [ 'id' => 2, 'email' => 'jane.doe@hotmail.com' ], ]; foreach ($arr2 as ['id' => $id, 'email' => $lookup[$id][]]); foreach ($arr1 as ['id' => $id, 'email' => &$email]) { $email = array_merge((array) $email, $lookup[$id] ?? []); } var_export($arr1);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 1, 'name' => 'John', 'email' => array ( 0 => 'j@mail.com', 1 => 'john@yahoo.com', ), ), 1 => array ( 'id' => 2, 'name' => 'Jane', 'email' => array ( 0 => 'jane@mail.com', 1 => 'jane@yahoo.com', 2 => 'jane.doe@hotmail.com', ), ), )

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