php - Array merge at second level -


i have 2 arrays shown below. need merge content of arrays can structure shown in third array @ last. have checked array_merge can't figure out way possible. appreciated. thanks.

array(     (int) 0 => array(         'gross_value' => '100',         'quantity' => '1'     ),     (int) 1 => array(         'gross_value' => '200',         'quantity' => '1'     ) )  array( (int) 0 => array(     'item_title_id' => '1',     'order_id' => '4' ), (int) 1 => array(     'item_title_id' => '2',     'order_id' => '4' ) ) 

i should merged array this

array( (int) 0 => array(     'gross_value' => '100',     'quantity' => '1',     'item_title_id' => '1',     'order_id' => 4 ), (int) 1 => array(     'gross_value' => '200',     'quantity' => '1',     'item_title_id' => '2',     'order_id' => 4 ) 

)

use array_merge_recursive :

convert numeric key strings, (make associative array)

$result = array_merge_recursive($ar1, $ar2); print_r($result); 

see live demo here


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -