2

I know there are a lot of smart people, so prove me right!

I want to combine arrays where similar named keys merge together to form a single array. See example:

[Bob] => Array
(
    [BobsDetails] => Array
    (
       [Title] => Mr
    )
)

[Bob] => Array
(
    [BobsDetails] => Array
    (
         [Surname] => Smith
     )
)

How do I end up with ONE array that looks like:

[Bob] => Array
(
    [BobsDetails] => Array
        (
            [Title] => Mr
            [Surname] => Smith
        )
)

Thanks in advance guys

PS I dont think it is as simple as array_merge... ;(

EDIT Made it easier to read

EDIT Sorted. Thanks for the help. array_merge_recursive worked

  • 3
    I think renaming your question to better identify the content would be a good idea - especially for people searching the archives. – sangretu Jul 20 '09 at 17:53

1 Answers1

7

I believe you just have to array merge $array['Basic'] instead of just $array;

Actually, if you use array_merge_recursive() on $array it will work. (Check for recursive versions of common functions for multi-dimensional arrays)

Tyler Carter
  • 60,743
  • 20
  • 130
  • 150