首页 新闻 搜索 专区 学院

PHP数组操作问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2016-06-21 13:15

原数组

Array
(
    [0] => Array
        (
            [activity_id] => 2
            [applyid] => 5
            [name] => 王
            [mobile] => 1366666666
            [signed] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 一次签到
                            [create_time] => 1465181547
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [1] => Array
                        (
                            [id] => 3
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 二次签到
                            [create_time] => 1465182225
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [2] => Array
                        (
                            [id] => 4
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 三次签到
                            [create_time] => 1465189536
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [3] => Array
                        (
                            [0] => 1463056434
                            [1] => 1
                        )

                    [4] => Array
                        (
                            [0] => 1463074455
                            [1] => 3
                        )

                )

        )

    [1] => Array
        (
            [activity_id] => 2
            [applyid] => 6
            [name] => zhang
            [mobile] => 
            [signed] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 一次签到
                            [create_time] => 1465181547
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [1] => Array
                        (
                            [id] => 3
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 二次签到
                            [create_time] => 1465182225
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [2] => Array
                        (
                            [id] => 4
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 三次签到
                            [create_time] => 1465189536
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] => 
                        )

                    [3] => Array
                        (
                            [0] => 1463036123
                            [1] => 4
                        )

                )

        )

)

要把对应的time赋值到上面

幻月无痕的主页 幻月无痕 | 初学一级 | 园豆:105
提问于:2016-06-21 10:33
< >
分享
所有回答(1)
0

 for($i=0;$i<count($new_rst);$i++){
            for($j=0;$j<count($new_rst[$i]['signed']);$j++){
                for($k=0;$k<count($result);$k++){
                    if($new_rst[$i]['signed'][$j]['id']==$result[$k]['typeid'] && $new_rst[$i]['name']==$result[$k]['name']){
                        $new_rst[$i]['signed'][$j]['time']=$result[$k]['signedtime'];
                        break;
                    }
                }
            }
        }  

幻月无痕 | 园豆:105 (初学一级) | 2016-06-21 13:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册