How to merge subarray in PHP most easily?

后端 未结 7 567
渐次进展
渐次进展 2020-12-03 22:32
$arr[] = array(\'A\',\'B\');
$arr[] = array(\'C\',\'B\');
...

I need to get the merged result of all sub array of $arr .

And f

7条回答
  •  没有蜡笔的小新
    2020-12-03 23:09

    A simple way to handle this in PHP Version >= 5.6 is to use the splat operator also called Argument Unpacking.

    $arr = array_unique(array_merge(...$arr));
    

提交回复
热议问题