博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 两个二维数组重组新数组,数组下标不同
阅读量:6694 次
发布时间:2019-06-25

本文共 2186 字,大约阅读时间需要 7 分钟。

 
Array(    [0] => Array        (            [PosNum] => 27025008            [start_time] => 20180328164929            [type] => 0        )    [1] => Array        (            [PosNum] => 27065075            [start_time] => 20180328164939            [type] => 1        )    [2] => Array        (            [PosNum] => 27065684            [start_time] => 20180329164918            [type] => 2        )    [3] => Array        (            [PosNum] => 27065099            [start_time] => 20180329165556            [type] => 3        ))
 

 

Array(    [5] => Array        (            [StudentNumber] => 20116161            [PosNum] => 27025008            [judgmenttime] => 20180328164929            [type] => 0        )    [0] => Array        (            [StudentNumber] => 3333号            [PosNum] => 27065075            [judgmenttime] => 20180328164939            [type] => 1        )    [4] => Array        (            [StudentNumber] => 123654789            [PosNum] => 27065684            [judgmenttime] => 20180329164918            [type] => 2        )    [2] => Array        (            [StudentNumber] => 232222222            [PosNum] => 27065099            [judgmenttime] => 20180329165556            [type] => 3        )    [1] => Array        (            [StudentNumber] => 11111111            [PosNum] => 27065188            [judgmenttime] => 20180328165123            [type] => 0        )    [3] => Array        (            [StudentNumber] => 3333333            [PosNum] => 27065066            [judgmenttime] => 20180328162058            [type] => 4        ))

 

//重组数组        $arr1 = array();        foreach ($res as $k => $v) {            //多的数组            foreach ($result as $ke => $va) {                //少的数组为主                if ($v['PosNum'] == $va['PosNum']) {                    $arr1[$ke]['StudentNumber'] = $va['StudentNumber'];                    $arr1[$ke]['PosNum']        = $va['PosNum'];                    $arr1[$ke]['judgmenttime']  = $v['start_time'];                   // $arr1[$ke][$type[$v['type']]] = $v['start_time'];                    $arr1[$ke]['type'] =$v['type'];                }            }        }

 

转载于:https://www.cnblogs.com/yszr/p/8682392.html

你可能感兴趣的文章
Fiddler抓包工具总结二(转自小坦克)
查看>>
JSP----动态网页开发的基础
查看>>
CentOS 6.5下部署日志服务器 Rsyslog+LogAnalyzer+MySQL
查看>>
[TFS]安装/升级TFS2012
查看>>
HLG 1408 漩涡
查看>>
径向渐变旋转的圆球
查看>>
LoadRunner使用之变量参数化
查看>>
asp.net运行原理
查看>>
canvas实现芝麻信用评分效果
查看>>
053(五十三)
查看>>
【Spark篇】---Spark中yarn模式两种提交任务方式
查看>>
最短路专题解题报告
查看>>
什么是FSO
查看>>
批处理程序如何接受多个文件拖入?开启了变量延迟enabledelayedexpansion之后遇到感叹号要怎么处理?...
查看>>
java中判断一个字符串是否“都为数字”和“是否包含数字”和“截取数字”
查看>>
Python 3
查看>>
实现主从关系Form中汇总行金额/数量
查看>>
Python学习笔记:协程
查看>>
原生js完成拼图小游戏
查看>>
[Algorithms] Radix Sort
查看>>