array_merge 和 array + array 有什么区别? [英] What's the difference between array_merge and array + array?

查看:51
本文介绍了array_merge 和 array + array 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个相当简单的问题.有什么区别:

A fairly simple question. What's the difference between:

$merged = array_merge($array1, $array2);

$merged = $array1 + $array2;

?

推荐答案

区别在于:

+ 运算符采用两个数组的联合,而 array_merge 函数采用联合重复键被覆盖.

The + operator takes the union of the two arrays, whereas the array_merge function takes the union BUT the duplicate keys are overwritten.

这篇关于array_merge 和 array + array 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆