简体   繁体   English

将两个数组合并为一个

[英]Merge two arrays into one

I know there is suck thing in stack overflow, but, all of the different case with my case, different structure of array, and I can not implement in my case. 我知道堆栈溢出中有糟糕的事情,但是,我的情况,数组的结构都不同,并且无法在我的情况下实现。

I have two arrays. 我有两个数组。

First: 第一:

  Array
    (
        [seriesname] => rencana
        [data] => Array
            (
                [0] => Array
                    (
                        [value] => 70
                    )

                [xxx] => Array
                    (
                        [value] => xxx
                    )
            )
    )

And second: 第二:

Array
(
    [seriesname] => realisasi
    [data] => Array
        (
            [0] => Array
                (
                    [value] => 20
                )
            [xxx] => Array
                (
                        [value] => xxx
                )

        )

)

I have tried array_merge($first,$second); 我试过array_merge($first,$second); , and seriesname has gone in returned array. ,并且seriesname已放入返回的数组中。 array_push($first,$second); returns nothing. 什么也不返回。

What function or what am I missing? 我缺少什么功能?

Thanks. 谢谢。

By the way here we go the goal that I want to achieve: 顺便说一下,我们要达到我要实现的目标:

result 结果

array (
[seriesname] => rencana
    [data] => Array
        (
            [0] => Array
                (
                    [value] => 70
                )

            [xxx] => Array
                (
                   [value] => xxx
                )

        ),
[seriesname] => realisasi
    [data] => Array
        (
            [0] => Array
                (
                    [value] => 20
                )

            [xxx] => Array
                (
                    [value] => xxx
                )

        )
)

您可以将其存储在一个数组中-

$new = array($first,$second);

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

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