FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Joining two arrays?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Joining two arrays? [message #174415] Fri, 10 June 2011 18:14 Go to previous message
Mike is currently offline  Mike
Messages: 18
Registered: December 2010
Karma:
Junior Member
How can I combine two 2-dimensional arrays into a single array using a
matching key value. Here's an example:

I have these two arrays:

$arr1 = array(
array('key'=>7, 'first_name'=>'Joe'),
array('key'=>14, 'first_name'=>'Susan')
);
$arr2 = array(
array('key'=>14, 'last_name'=>'Doe'),
array('key'=>7, 'last_name'=>'Anderson')
);

I want to create a second array JOINing the two based on the key
value, giving me:

$resulting_arr = array(
array('key'=>7, 'first_name'=>'Joe','last_name'=>'Anderson'),
array('key'=>14, 'first_name'=>'Susan','last_name'=>'Doe')
);

Thanks!

Mike
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Setting PDO::ATTR_ERRMODE to E_WARNING before connecting!
Next Topic: haiii
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 21:52:52 GMT 2024

Total time taken to generate the page: 0.06004 seconds