php - Merge two multidimensional arrays, preserve numeric keys, and combine values inside array -


i have 2 arrays , combine / merge / put them together.

$arr1 = array(     0 => array(1, 2),     1 => array(5, 6) );  $arr2 = array(     0 => array(2, 3),     1 => array(6, 7) );      come_together_right_now($arr1, $arr2); // missing function? 

and result be:

array (      [0] => array (          [0] => 1          [1] => 2          [2] => 3      )     [1] => array (          [0] => 5          [1] => 6          [2] => 7      ) 

there way many array functions! array_merge , array_combine , recursive alternatives seem replace values , don't preserve numeric keys. how do this?

assuming have same keys!

$result = array();  foreach($arr1 $key=>$array) {     $result[$key] = array_merge($array, $arr2[$key]); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -