views:

147

answers:

1

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

+6  A: 

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)

Chacha102
So yeah, it is as simple as array_merge(). :P
Chacha102
http://api.cakephp.org/view_source/set/#l-39
deizel
Thanks my love.And Chaacha102: Goddamn you.