bigdaveygeorge
bigdaveygeorge

Reputation: 999

Combining 2 arrays into 1

If I have an array like this:

$array = Array( 
    array(
        [a] => something, 
        [b] => something
    )
)

Then I have another array the same, if I want to combine them to create an array like this:

Array( 
    [0] => Array( 
        [a] => something, 
        [b] => something
    )
    [1] => Array( 
        [a] => something, 
        [b] => something
    )
)

How can I achieve that? I thought using array_merge would help but that gives me:

Array( 
    [0] => Array( 
        [a] => something, 
        [b] => something
    )
    [1] => something, 
    [2] => something
    )
)

Upvotes: 0

Views: 26

Answers (1)

Condorcho
Condorcho

Reputation: 503

Well, I just tried this and it worked:

$new_array = array(
    $array_one,
    $array_two,
);

Try it yourself here.

Upvotes: 1

Related Questions