merge array of different length php -


let's have 2 arrays this:

$arr1 = array( array('position' => 1), array('position' => 2), array('position' => 3), array('position' => 4), array('position' => 5), array('position' => 6), array('position' => 7) );  $arr2 = array(       array(     'a' => 'a1',      'b' => 'b1',     'c' => 'c1' ), array(     'a' => 'a2',     'b' => 'b2',     'c' => 'c2' ), array(     'a' => 'a3',     'b' => 'b3',     'c' => 'c3' ) ); 

the goal have resulting array key position first array copied each array in second array this:

$final_arr = array( array(     'a' => 'a1',     'b' => 'b1',     'c' => 'c1',      'position' => 1 ), array(     'a' => 'a2',     'b' => 'b2',     'c' => 'c2',      'position' => 2 ), array(     'a' => 'a3',     'b' => 'b3',     'c' => 'c3',      'position' => 3 ) ); 

why can't array_merge? idea?

note can see above, arrays don't have same length

thank help

$new=array(); foreach ($arr2 $k=>$v){  $new[]=$v+$arr1[$k]; }  print_r($new); 

http://codepad.viper-7.com/tykewa


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -