PHP数组关联[重复]

This question already has an answer here:

Whats the easiest way to convert array a to b

a= [['x'=>'a'], ['y'=>'b']] 


b= ['x'=>'a', 'y'=>'b']

a and b are just two examples.

</div>

Using array_walk_recursive for arbitrary depth:

$b = [];
array_walk_recursive($a, function ($v, $k) use (&$b) { $new[$k] = $v; });

Using @splash58 trick with the spread operator if you have only one level deep:

$b = array_merge(...$a);