php - How to work with integrate 2 different array? -


i working 2 different array want integrate both of become result want. have no idea how it.

this array return current result me :

foreach($getvote $option){         $data['id'] = $option['option_id'];         $data['option'] = $option['option'];     } 

and result :

array ( [id] => array ( [0] => 1 [1] => 2 )          [option] => array ( [0] => option 1 id 2 [1] => option 2 id 2 ) ) 

but want :

array ([0]=>array( [id] => 1 [option] => option 1 id 2)         [1]=>array( [id] => 2 [option]=> option 2 id 2 ) ) 

this $getvote result :

array ([0] => array ( [id] => 2         [option_id] => array ( [0] => 1 [1] => 2 )         [option] => array ( [0] => option 1 id 2 [1] => option 2 id 2 )         [subject] => test 2         [type] => 1 ) ) 

i don't know asking correct question. hope can all. in advanced.

try

 for($i =0; $i<count($getvote[0]['option_id']); $i++) {      $data[$i]['id'] = $getvote[0]['option_id'][$i];       $data[$i]['option'] = $getvote[0]['option'][$i];    } 

output :-

array (     [0] => array         (             [id] => 1             [option] => option 1 id 2         )      [1] => array         (             [id] => 2             [option] => option 2 id 2         )  ) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -