PHP重置没有循环的数组的第一级

I have a simple multidimensional array like the following

$array = array(
    array('key1'=>array('a','b')),
    array('key2'=>array('c','d'), 'key3'=>array('e','f')),
    array('key4'=>array('g','h'), 'key5'=>array('i','j'), 'key6'=>array('k','l', 'm'))
);

and I would reset its first level like the following

$array = array(
    'key1'=>array('a','b'),
    'key2'=>array('c','d'),
    'key3'=>array('e','f'),
    'key4'=>array('g','h'),
    'key5'=>array('i','j'),
    'key6'=>array('k','l','m')
);

I know it's quite easy with a foreach loop to achieve, but I'm wondering if it's possible to do it using one line code.

What I tried so far

array_map('key', $array);

but it returns only the first key of child array.

Any thoughts?

PHP 5.6 introduce the variadic functions in PHP, which allow one to write funtions that take any additional argument into the same array using the splat operator : ... .

The other - maybe fairly less known - use of that operator is that it works the other way around. By placing that operator before an array in a function's call, it makes that function to take the entries of that array as if you wrote them inline.

Which allows you to type :

$array = array_merge(... $array);

Sending $array would usually return $array unchanged. Using the splat makes array_merge to work on the undefined amount of 2nd level arrays in it. Since array_merge is itself a variadic function that merge any arrays you send to it, it works.

try this: made it work with array_reduce.

$result = array_reduce($array, function($final, $value) {
    return array_merge($final, $value);
}, array());

online example