PHP array_merge_recursive()函数 (PHP array_merge_recursive() function)

array_merge_recursive() function is used to merge two or more arrays, it returns a new array with merged elements. The only difference between array_merge() and array_merge_recursive() function is: "It merges the values having the same key as an array instead of overriding the values."

array_merge_recursive()函数用于合并两个或多个数组,它返回一个具有合并元素的新数组。 “ array_merge()和array_merge_recursive()函数之间的唯一区别是: “它合并与数组具有相同键的值,而不是覆盖这些值。”

Syntax:

句法:

    array_merge_recursive(array1, array2,...);

It accepts two or more arrays and returns a new array with merged elements.

它接受两个或多个数组,并返回带有合并元素的新数组。

Examples:

例子:

    Input:
$arr1 = array("a" => "Hello", "b" => "Hi");
$arr2 = array("a" => "Okay!", "d" => "Nothing");
Output:
Array
(
[a] => Array
(
[0] => Hello
[1] => Okay!
)
[b] => Hi
[d] => Nothing
)

PHP code:

PHP代码:

<?php
$arr1 = array("a" => "Hello", "b" => "Hi");
$arr2 = array("a" => "Okay!", "d" => "Nothing");
//merging arrays
$arr3 = array_merge_recursive($arr1, $arr2);
//printing
print_r ($arr3);
?>

Output

输出量

Array
(
[a] => Array
(
[0] => Hello
[1] => Okay!
)
[b] => Hi
[d] => Nothing
)

翻译自: https://www.includehelp.com/php/array_merge_recursive-function-with-example.aspx

PHP array_merge_recursive()函数与示例相关推荐

  1. php指定长度 分割整形,php指定长度分割字符串str_split函数用法示例

    本文实例讲述了php指定长度分割字符串str_split函数用法.分享给大家供大家参考,具体如下: 示例1:$str = 'abcdefgh'; $arr = str_split($str,2); 运 ...

  2. getdate函数_PHP getdate()函数与示例

    getdate函数 PHP getdate()函数 (PHP getdate() function) getdate() function is used to get the local date/ ...

  3. 安卓log.e函数打印示例_log1p()函数以及C ++中的示例

    安卓log.e函数打印示例 C ++ log1p()函数 (C++ log1p() function) log1p() function is a library function of cmath ...

  4. gettimeofday_PHP gettimeofday()函数与示例

    gettimeofday PHP gettimeofday()函数 (PHP gettimeofday() function) gettimeofday() function is used to g ...

  5. dir函数_PHP dir()函数与示例

    dir函数 PHP dir()函数 (PHP dir() function) dir() function is an instance of the directory class, it is u ...

  6. PHP rewinddir()函数与示例

    PHP rewinddir()函数 (PHP rewinddir() function) rewinddir() function is used to rewind/reset the direct ...

  7. stl swap函数_C ++ STL | vector :: swap()函数与示例

    stl swap函数 C ++ STL vector :: swap()函数 (C++ STL vector::swap() function) vector::swap() function is ...

  8. C#回调函数应用示例,形象比喻方法助理解

    C#回调函数应用示例,形象比喻方法助理解,整理了一个简单的例子来说明回调函数的用法: namespace CallBackFunction {     class Program     {      ...

  9. php解escape,PHP下escape解码函数用法示例

    这篇文章主要为大家详细介绍了PHP下escape解码函数用法示例,具有一定的参考价值,可以用来参考一下. 感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧!GB2312编码: 代码如下: fu ...

最新文章

  1. 【MongoDB异常】Exception authenticating MongoCredential解决方法
  2. TiKV 成功晋级 CNCF 孵化项目
  3. 恒安嘉新面试题java_【恒安嘉新面试|面试题】-看准网
  4. IGMP Internet组管理协议 未完
  5. 内核地址空间和用户地址空间
  6. 前端构建工具gulpjs的使用介绍及技巧 (转)
  7. 在Ubuntu上为Android系统编写Linux内核驱动程序
  8. sqlserver evaluation是什么版本_使用SSMS扫描和查找SQL Server数据库的潜在安全漏洞...
  9. [转]GridView 72般绝技
  10. 最短路径问题:Dijkstra算法详解
  11. Linux logo和屏幕光标
  12. curl之采集QQ空间留言
  13. Android Broadcast Receiver 与Activity() (android 开发的四大组件)
  14. HTML和CSS面试题第35题
  15. 国内外卫星数据查询地址
  16. firefox火狐浏览器显示多列书签菜单
  17. Node.js meitulu图片批量下载爬虫1.03版
  18. statsmodels.stats.proportion.proportions_ztest
  19. Vue脚手架热更新技术探秘
  20. matlab中参数估计,关于matlab的参数估计

热门文章

  1. js 常用类型转换简写
  2. CSS未知宽高元素水平垂直居中
  3. axios请求超时,设置重新请求的完美解决方法
  4. 点a链接写邮件小技巧
  5. JavaScript日期格式化处理
  6. bzoj2375 疯狂的涂色
  7. 【NIO】之IO和NIO的区别
  8. ADO.NET 核心对象简介
  9. css3中的background
  10. ORACLE基本SQL语句-查询篇