View Single Post
Old 10-24-2009, 03:15 AM   #1 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default Array merge on similar key => value

I have three arrays I'm working with based on queries pulled from a database. All of them have one key => value pair in common, and I'm looking for the most elegant way to merge these arrays.

array_merge() of course won't work, and I'm curious if there's a better solution than iterating through and merging it 'by hand' so to speak within a loop.

For example, the arrays all follow this paradigm;

Code:
Array
(
    [0] => Array
        (
            [timestamp] => 2009-10-23
            [key_one] => value_one
        )

....

Array
(
    [0] => Array
        (
            [timestamp] => 2009-10-23
            [another_key] => another_value

        )
The desired result, is of course;

Code:
Array
(
    [0] => Array
        (
            [timestamp] => 2009-10-23
            [key_one] => value_one
            [another_key] => another_value
        )
delayedinsanity is offline  
Reply With Quote