如何处理父数组的键?

How to handle a key (index) of a parent array? I'm getting numeric keys, but I need an index as a key. Example.

<?php

$arrayFirst = [
  "index" => [
    'a' => '1',
  ],
  [
    'a' => '2',
  ]
];
$arraySecond = [
  "index" => [
    'b' => '1',
  ],
  [
    'b' => '2',
  ]
];
var_dump(array_map(function(...$items){
  return array_merge(...$items);
}, $arrayFirst, $arraySecond));

If keys of two arrays are complete the same, then you can try using func array_combine():

var_dump(
    array_combine(
        array_keys($arrayFirst),
        array_map(
            function(...$items) {
                return array_merge(...$items);
            },
            $arrayFirst,
            $arraySecond
        )
    )
);

Example

Here is one possible workaround:

$arrayFirst = array("index" => array("keyFirst" => "valFirst"));
$arraySecond = array("index" => array("keySecond" => "valSecond"));
$result = ['index' => array_merge($arrayFirst['index'], $arraySecond['index'])];

var_dump($result);

Example