tags:

views:

119

answers:

2

I have several associative arrays, each starting with a string key. I also have a master array that i want to use to combine each of these sub arrays. When using array_push though, each array is then given an additional numeric key in the master array.

How can i avoid this and push the sub arrays into the master array keeping the keys intact?

+1  A: 
$master_array = array_merge($master_array, $sub_array_1, $sub_array_2, ...) ;

Beware of what happens when the sub arrays have the same keys - if they are numeric, you will get both values, but if not, later values will over-write earlier ones.

Gus
A: 

Hello,

As you have not posted any example, it is difficult for me to visualize you code... however, I think you need to use "array_merge" function http://www.php.net/manual/en/function.array-merge.php

Hope that helped.

Accilies