$arrayOne = array('cat', 'dog', 'turkey');
$arrayTwo = array('peach', 'apple', 'banana');
foreach ($arrayTwo as $aRow) {
    $arrayOne[] = $aRow;
}

And we get this as a result:

Simple, but why do that when you can do this in one line using array_merge:

$newarray = array_merge($arrayOne, $arrayTwo);

and get this:

Array merge works with two or more arrays. Let's do it:

$arrayOne = array('cat', 'dog', 'turkey');
$arrayTwo = array('peach', 'apple', 'banana');
$arrayThree = array('dodge', 'ford', 'mazda');
$threeArrays = array_merge($arrayOne, $arrayTwo, $arrayThree);
new chk ($threeArrays);

And we get this:

As you can see newchk is easy to use, and you get great results. Let's get back to array_merge.

NULL ARRAYS

What if one of the arrays was a null?

X2 tema untuk hp tema hp samsung corby 2 tema hp nokia e63
Free tema hp nokia x2 free tema hp mito 866 tema hp nokia n73

833 tema hp nokia x2-01 tema hp samsung free tema hp x2

50 cent albums free
E63 tema hp nokia tema hp nokia e63 free tema mito 720

720 tema mito 901 tema mito 799 theme mito 303

$arrayOne = array('cat', 'dog', 'turkey'); $arrayTwo = array(); $arrayThree = array('dodge', 'ford', 'mazda'); $arrayNull = array_merge($arrayOne, $arrayTwo, $arrayThree);

Which results in:

So null arrays are just ignored.

ASSOCIATIVE KEYS

00 tema hp mito 868 tema hp x2 00 tema untuk hp nokia c3

833 tema hp cross gg51d tema mito 808 tema hp samsung galaxy young

500 themes mito 833 tema hp x2-01 tema hp samsung corby 2

2 tema hp x2 free theme hp mito 868 tema hp mito 9700

868 free tema mito 720 tema mito 9700 tema mito 711

Gratis free tema mito 9700 tema hp samsung galaxy mini tema untuk hp nokia x2-01
E63 tema hp nokia 5300 download theme mito 500 tema mito a300
833 tema hp nokia free tema mito 799 tema hp nokia 5300
Now let's look at associative arrays.

$arrayOne = array( 'animal1' =>'cat', 'animal2' =>'dog', 'animal3' =>'turkey');
$arrayTwo = array('fruit1' => 'peach', 'fruit2' => 'apple', 'fruit3' => 'banana');
$newarray = array_merge($arrayOne, $arrayTwo);

What we expect:

But what if we had the same key in each of arrays?

E3t tema untuk hp mito 868 tema hp mito 303 tema hp cross
868 tema hp cross tema hp free tema hp nokia x2
303 download aplikasi pembuat tema hp e63 tema hp n73 free tema hp e63 free
medi assist india tpa claim form

500 tema gratis untuk hp nokia download tema hp x2-02 tema hp cross pd 8

9700 tema hp samsung champ gt-c3303i tema hp nokia tema hp mito 808
9700 tema hp n73 free download tema hp e63 gratis tema hp nokia e63
833 tema untuk hp mito 720 tema hp e63 tema hp cross gg51d
$arrayOne = array( 'animal1' =>'cat', 'sameKey' =>'dog', 'animal3' =>'turkey'); $arrayTwo = array('fruit1' => 'peach', 'sameKey' => 'apple', 'fruit3' => 'banana'); $arrayThree = array( 'car1' => 'dodge', 'sameKey' => 'ford', 'car3' => 'mazda'); $newArr = array_merge($arrayOne, $arrayTwo, $arrayThree);

What I've done is put the same associative key in each array, and here are the results;

NUMERIC KEYS

What if we used intergers for keys, would we get the same results?

$arrayOne = array( 0 =>'cat', 2 =>'dog', 4 =>'turkey');
$arrayTwo = array( 0 => 'peach', 2  => 'apple', 4 => 'banana');
$newArr = array_merge($arrayOne, $arrayTwo);

ARRAY UNION

$arrayOne = array( 0 =>'cat', 2 =>'dog', 4 =>'turkey');
$arrayTwo = array( 0 => 'peach', 2  => 'apple', 4 => 'banana');
$unionArr =  $arrayOne +  $arrayTwo;

And we get:

Notice that the keys that are the same are ignored in the second array.

STRINGS

$arrayOne = 'The quick fox blew it by not turning this into an array";
$arrayTwo = array( 0 => 'peach', 2  => 'apple', 4 => 'banana');
$stringArr =  array_merge( $arrayOne , $arrayTwo);
new chk( $arrayOne, $arrayTwo , $stringMerge );

9700 tema hp free tema mito 799 tema hp nokia gratis

A200 tema mito 711 tema mito 566 tema untuk hp samsung champ

Nokia cara tema hp e63 tema hp nokia 6300 free free tema mito 833
X2-01 tema mito 901 tema hp x2 free tema untuk hp mito 720

nfs world free full version

566 themes mito 720 tema hp cross g900t tema hp e63 free
00 tema mito 868 tema untuk hp nokia c3 themes mito 833

720 free theme mito 9700 free tema mito 866 tema hp nokia free

$arrayOne = (array) 'The quick fox blew it by not turning this into an array"; $arrayTwo = array( 0 => 'peach', 2 => 'apple', 4 => 'banana'); $stringMerge = array_merge( $arrayOne , $arrayTwo); new chk( $arrayOne, $arrayTwo , $stringMerge );

And we get:

Now that we cast the string as an array, array_merge works as expected.

CLEANING ARRAYS

$arrayOne = array( 'animal1' =>'cat', 'animal2' =>'dog', 'animal3' =>'turkey');
$arrayTwo = array('fruit1' => '', 'sameKey' => '', 'fruit3' => 'banana');
$arrayThree = array( 'animal4' => 'cat', 'animal5' => 'lion', 'animal6' => 'turkey');

$uniqueArr = array_unique($mergeArr);
$filterArr = array_filter($uniqueArr);

And here are the last two arrays: