Possible Duplicate:
How can I merge PHP arrays?
I have two arrays, both results of db queries. I have a simple example below (no the real data- just for demo purposes. The real data is significantly more complex).
$results:
Array
( [0] =>
Array ( [id] => 20 [age] => 29 )
[1] =>
Array ( [id] => 593 [age] => 38 )
)
$persons:
Array
( [0] =>
Array ( [id] => 593 [name] => Jack Jones )
[1] =>
Array ( [id] => 20 [name] => John Smith )
)
My question is: how can I match the $persons[name] to replace $results[id] so that I end up with:
$results:
Array
( [0] =>
Array ( [id] => John Smith [age] => 29 )
[1] =>
Array ( [id] => Jack Jones [age] => 38 )
)
the arrays are unorderd - I need to replace values if the keys match (and yes, each key in $results definitely has a corresponding entry in $persons). Any help much appreciated!
idand yours is byname(which you should probably switch)