zoukankan      html  css  js  c++  java
  • php 两个二维数组重组新数组,数组下标不同

    
    
    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'];
                    }
                }
            }
  • 相关阅读:
    WebSocket来实现即时通讯
    微信小程序1
    使用phpqrcode来生成二维码/thinkphp
    PHP函数积累
    Docker 常用命令汇总(beta)
    Nginx+Keepalived高可用架构简述(beta)
    Docker镜像制作(以Nginx+Keepalived为例)(beta)
    开源协议浅谈(beta)
    【Elasticsearch系列】ES安装(mac)
    linux 下安装JDK
  • 原文地址:https://www.cnblogs.com/yszr/p/8682392.html
Copyright © 2011-2022 走看看