1
回答
PHP数组组装合并操作
数组$result=
Array
(
    [0] => Array
        (
            [id] => 5
            [activity_id] => 2
            [applyid] => 5
            [signedtime] => 1463056434
            [typeid] => 1
            [name] => 王
            [mobile] => 
        )

    [1] => Array
        (
            [id] => 8
            [activity_id] => 2
            [applyid] => 5
            [signedtime] => 1463074455
            [typeid] => 3
            [name] => 王
            [mobile] => 
        )

    [2] => Array
        (
            [id] => 16
            [activity_id] => 2
            [applyid] => 6
            [signedtime] => 1463036123
            [typeid] => 4
            [name] => zhang
            [mobile] => 
        )

)


数组$signedtime=
Array
(
    [0] => Array
        (
            [id] => 1
            [activityid] => 2
            [activityname] => 测试数据2多次签到
            [signedname] => 一次签到
            [create_time] => 1465181547
            [listorder] => 0
            [sign_img] => 
            [type] => 
        )

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

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

)




要求结果:
Array
(
    [0] => Array
        (
            [activity_id] => 2
            [name] => 王
            [mobile] => 
            [signed] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [activityid] => 2
                            [activityname] => 测试数据2多次签到
                            [signedname] => 一次签到
                            [create_time] => 1465181547
                            [listorder] => 0
                            [sign_img] => 
                            [type] => 
                            [time] =>1463056434
                        )

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

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

                )

        )

    [1] => Array
        (
            [activity_id] => 2
            [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]=>1463036123
                        )

                   
                )

        )

)

其中$result中applyid相同的合并,$result中的replyid等于$signedname中的id




PHP
举报
werwerds
发帖于2年前 1回/365阅
顶部