首页 技术 正文
技术 2022年11月11日
0 收藏 463 点赞 5,146 浏览 2223 个字
 <?php //追加数组 array_merge_recursive()函数与array_merge()相同,可以将两个或多个数组合并在一起,形成一个联合的数组.两者之间的区别在于,当某个输入数组中的某个键己经存在于结果数组中时该函数会采取不同的处理方式.array_merge()会覆盖前面存在的键/值对,替换为当前输入数组中的键/值对,而array_merge_recursive()将把两个值合并在一起,形成一个新的数组,并以原有的键作为数组名。还有一个数组合并的形式,就是递归追加数组 $arr=array(     '0'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'110',//帐变余额             'time'=>'2016-01-21', //参与时间             'cash'=>'160',//帐变金额     ),     '1'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'130',//帐变余额             'time'=>'2016-01-22', //参与时间             'cash'=>'150',//帐变金额     ),     '2'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'150',//帐变余额             'time'=>'2016-01-20', //参与时间             'cash'=>'140',//帐变金额     ), ); $arr2=array(     '0'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'110',//帐变余额             'time'=>'2016-01-21', //参与时间             'cash'=>'160',//帐变金额     ),     '1'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'130',//帐变余额             'time'=>'2016-01-22', //参与时间             'cash'=>'150',//帐变金额     ),     '2'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'150',//帐变余额             'time'=>'2016-01-20', //参与时间             'cash'=>'140',//帐变金额     ), ); $new_arr=array(); $new_arr=array(     '0'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'110',//帐变余额             'time'=>'2016-01-21', //参与时间             'cash'=>'160',//帐变金额     ),     '1'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'130',//帐变余额             'time'=>'2016-01-22', //参与时间             'cash'=>'150',//帐变金额     ),     '2'=>array(             'purchase_type'=>'1', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'150',//帐变余额             'time'=>'2016-01-20', //参与时间             'cash'=>'140',//帐变金额     ),     '3'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'110',//帐变余额             'time'=>'2016-01-21', //参与时间             'cash'=>'160',//帐变金额     ),     '4'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'130',//帐变余额             'time'=>'2016-01-22', //参与时间             'cash'=>'150',//帐变金额     ),     '5'=>array(             'purchase_type'=>'0', //0 带入  1 带出             'app_id'=>'1234567890abcdef', //游戏类别             'out_aft_change'=>'150',//帐变余额             'time'=>'2016-01-20', //参与时间             'cash'=>'140',//帐变金额     ), ); echo '<pre>'; print_r(array_merge_recursive($arr, $arr2)); echo '</pre>'; ?>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,299