php Multidimensional array question -


so have array following:

array (     [0] => array         (             [user_id] => 684             [sec_id] => 2             [rank_id] => 1             [rank] => usr          )      [1] => array         (             [user_id] => 693             [sec_id] => 3             [rank_id] => 5             [rank] => usr          ) ) 

and have array this

array (     [0] => 2     [1] => 7     [2] => 27 ) 

i want value of second array added @ end of each arrays of 1st array, , should multiplied. mean, if have 100 arrays in first array, , 3 elements in second array, should have 300 in resulting array.

taking example of above, have follows:

user_id | sec_id | rank_id | rank | menu_id 684 |        2 |       1 |    usr |    2 684 |        2 |       1 |    usr |    7 684 |        2 |       1 |    usr |   27 693 |        3 |       5 |    usr |    2 693 |        3 |       5 |    usr |    7 693 |        3 |       5 |    usr |   27 

i tried following function, it's not working.

function getr($arr_one,$arr_two) {     foreach ($arr_one $k=>&$v) {         foreach ($arr_two $x=>&$y) { $v['menu_id'] = $y;  }     }     return $arr_one;  } 

this making array this:

user_id | sec_id | rank_id | rank | menu_id 684 |        2 |       1 |    usr |   27 693 |        3 |       5 |    usr |   27 

means, it's adding menu_id @ end of each element of first array, not multiplying. idea, i'm surely missing something.

thanks guys.

function getr($arr_one,$arr_two) {     $new_arr = array();     foreach ($arr_one $k=>$v) {         foreach ($arr_two $x=>$y) {             $this_item = $v;             $this_item['menu_id'] = $y;             $new_arr[] = $this_item;         }     }     return $new_arr;  } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -