Merge 2 arrays with no duplicated keys

后端 未结 2 629
逝去的感伤
逝去的感伤 2021-01-21 18:09

I have 2 arrays like below and want to merge them together and not duplicate keys into a new array.

$array1:

Array
(
[0] => Array
    (
        [a] =&         


        
2条回答
  •  渐次进展
    2021-01-21 18:37

    Have you tried user custom examples/functions from the array_merge page? http://php.net/manual/en/function.array-merge.php

    There seem to be quite a few examples that might fit your bill. One suggestion for keeping keys (no renumbering) is to use the + operator

    $result = $x1 + $x2 (where x's are arrays)

提交回复
热议问题