3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array ( 0 => array ( 'agent_id' => 1, 'details' => array ( 1 => 100, 3 => -10, 2 => 0 ), ), 1 => array ( 'agent_id' => 2, 'details' => array ( 1 => 0, 3 => -5, 2 => -50 ), ), 2 => array ( 'agent_id' => 3, 'details' => array ( 1 => 50, 3 => 0, 2 => 0 ), ), 3 => array ( 'agent_id' => 4, 'details' => array ( 1 => 50, 3 => 0, 2 => 0 ), ) ); $array2 = array ( 0 => array ( 'id' => 10, 'agent_Id' => 1, 'total' => 90, 'room_Id' => 1, 'user_Id' => 1 ), 1 => array ( 'id' => 10, 'agent_Id' => 3, 'total' => 90, 'room_Id' => 1, 'user_Id' => 1 ), 2 => array ( 'id' => 10, 'agent_Id' => 4, 'total' => 90, 'room_Id' => 1, 'user_Id' => 1 ), 3 => array ( 'id' => 10, 'agent_Id' => 2, 'total' => 90, 'room_Id' => 1, 'user_Id' => 1 ) ); foreach ($array1 as $value) { $key = array_search($value['agent_id'], array_column($array2, 'agent_Id')); if ($key !== false) { $array2[$key]['details'] = $value['details']; } } print_r($array2);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => 10 [agent_Id] => 1 [total] => 90 [room_Id] => 1 [user_Id] => 1 [details] => Array ( [1] => 100 [3] => -10 [2] => 0 ) ) [1] => Array ( [id] => 10 [agent_Id] => 3 [total] => 90 [room_Id] => 1 [user_Id] => 1 [details] => Array ( [1] => 50 [3] => 0 [2] => 0 ) ) [2] => Array ( [id] => 10 [agent_Id] => 4 [total] => 90 [room_Id] => 1 [user_Id] => 1 [details] => Array ( [1] => 50 [3] => 0 [2] => 0 ) ) [3] => Array ( [id] => 10 [agent_Id] => 2 [total] => 90 [room_Id] => 1 [user_Id] => 1 [details] => Array ( [1] => 0 [3] => -5 [2] => -50 ) ) )

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:
116.99 ms | 1837 KiB | 4 Q