PHP combine arrays into one big array

Go To StackoverFlow.com

3

Is it possible to combine arrays, and basically append them to one big array like this:

$a = array(1,2,3,4);
$b = array(5,6,7,8);
$c = array(1,2,3,4);

so that the output would be:

$result = array(1,2,3,4,5,6,7,8,1,2,3,4);

Is this possible?

Thanks for your helps!

2012-04-05 19:07
by d-_-b


19

http://php.net/manual/en/function.array-merge.php

$a = array(1,2,3,4);
$b = array(5,6,7,8);
$c = array(1,2,3,4);

$out = array_merge($a, $b, $c);

Result:

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 1
    [9] => 2
    [10] => 3
    [11] => 4
)
2012-04-05 19:08
by Cal
Thanks! I read that before but the example#2 confused me, so I thought I'd ask on here... Thanks again! - d-_-b 2012-04-05 19:11
Ads