简体   繁体   English

重建php数组结构

[英]Rebuild php array structure

I've been looking for the follow solution to create the array structure I need.我一直在寻找以下解决方案来创建我需要的数组结构。

For aa list with updates for a specific user who can be following different things, I need to get first the followed items and the data compare to this item.对于可以关注不同事物的特定用户的更新列表,我需要首先获取关注的项目并将数据与该项目进行比较。 my output for this is as follow.我的 output 如下。

array how it is right now数组现在的情况

Array
(
    [0] => Array
        (
            [website_id] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [follower_id] => 1
                        )

                    [1] => Array
                        (
                            [id] => 1
                            [follower_id] => 2
                        )

                    [2] => Array
                        (
                            [id] => 1
                            [follower_id] => 3
                        )

                    [3] => Array
                        (
                            [id] => 1
                            [follower_id] => 4
                        )

                    [4] => Array
                        (
                            [id] => 1
                            [follower_id] => 5
                        )
                )
        )

    [1] => Array
        (
            [website_id] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [follower_id] => 1
                        )
                )
        )
)

I want to create the above array like tho on below我想像下面一样创建上面的数组

array like it has to be必须是这样的数组

Array
(
    [0] => Array
        (
                    [0] => Array
                        (
                            [id] => 1
                            [follower_id] => 1
                        )

                    [1] => Array
                        (
                            [id] => 1
                            [follower_id] => 2
                        )

                    [2] => Array
                        (
                            [id] => 1
                            [follower_id] => 3
                        )

                    [3] => Array
                        (
                            [id] => 1
                            [follower_id] => 4
                        )

                    [4] => Array
                        (
                            [id] => 1
                            [follower_id] => 5
                        )


                    [5] => Array
                        (
                            [id] => 1
                            [follower_id] => 1
                        )
)

Thanks in advice.谢谢指教。

With kind regards,亲切的问候,

Nicky尼基

Seems to me that array_merge() should be sufficient:在我看来, array_merge()应该足够了:

$newArray = array_merge($myArray[0]['website_id'], $myArray[1]['website_id']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM