php - joining / merging two arrays -


i have 2 arrays this, mysql data retrieved 2 different servers:

$array1 = array (                    0 => array ( 'id' => 1, 'name' => 'somename') ,                   1 => array ( 'id' => 2, 'name' => 'somename2')  ); $array2 = array (                    0 => array ( 'thdl_id' => 1, 'otherdate' => 'spmethings') ,                   1 => array ( 'thdl_id' => 2, 'otherdate' => 'spmethings22')  ); 

how can join / merge array looks this

$new_array = array (           0 => array ( 'id' => 1, 'name' => 'somename', 'otherdate' => 'spmethings') ,          1 => array ( 'id' => 2, 'name' => 'somename2', 'otherdate' => 'spmethings22')  ); 

it possible i'm misunderstanding, you're looking for?

for ($i = 0; $i < count($array1); $i++){     $new_array[$i] = array_merge($array1[$i], $array2[$i]);     unset($new_array[$i]['thdl_id']); //since i'm assuming duplicate of 'id' } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -