3v4l.org

run code in 300+ PHP versions simultaneously
<?php $orders = array ( 0 => array ( 'order_id' => 45145, 'customers_email_address' => 'test@test.com', 'customers_name' => 'testname' ), 1 => array ( 'order_id' => 45136, 'customers_email_address' => 'test@yahoo.com', 'customers_name' => 'testname' ), 2 => array ( 'order_id' => 45117, 'customers_email_address' => 'test@yahoo.com', 'customers_name' => 'testname' ), 3 => array ( 'order_id' => 44959, 'customers_email_address' => 'test@gmail.com', 'customers_name' => 'testname' ), 4 => array ( 'order_id' => 44938, 'customers_email_address' => 'test@hotmail.com', 'customers_name' => 't' ) ); $chitchattracking = array ( 1 => array ( 'order_id' => 44938, 'carrier_tracking_code' => 9205590221582717655498 ), 2 => array ( 'order_id' => 44854, 'carrier_tracking_code' => 92055902215827 ) ); $tracking = array(); $chitchat = array_column($chitchattracking, null, 'order_id'); foreach ($orders as $order) { $order_id = $order['order_id']; if (isset($chitchat[$order_id])) { $tracking[] = array_merge($order, $chitchat[$order_id]); } } print_r($tracking);
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Array ( [0] => Array ( [order_id] => 44938 [customers_email_address] => test@hotmail.com [customers_name] => t [carrier_tracking_code] => 9.2055902215827E+21 ) )

preferences:
147.36 ms | 408 KiB | 5 Q