Merging two multidimensional arrays on specific key

前端 未结 7 2242
南方客
南方客 2020-11-28 13:13

Let\'s say I have following arrays:

Array
    (
        [0] => Array
            (
                [id] => 5
                [name] => Education
            


        
7条回答
  •  心在旅途
    2020-11-28 13:28

    Make sure that the items are in the same order then:

    $items = array_map(function($itemFirstArray, $itemSecondArray) {
      return array_merge($itemFirstArray, $itemSecondArray);
    }, $firstArray, $secondArray);
    

提交回复
热议问题