cangak
cangak

Reputation: 132

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); , and seriesname has gone in returned array. 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
                )

        )
)

Upvotes: -1

Views: 57

Answers (1)

Sougata Bose
Sougata Bose

Reputation: 31749

You can store the in one array -

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

Upvotes: 1

Related Questions