how to insert elements single array into multidimensional array php -


i have been trying no luck combine 1 array another, multidimensional array. first array, $id1, created mysql query. second array, $pictures1, created scandir , hold 24 .jpg file pointers. have tried array_merge, array_splice, among others, , variety of looping functions. no avail. have read many forums on combining arrays no luck. i'm new php, , think i'm missing basic here. appreciate direction or insight on correct way go. these arrays:

$pictures1

array    (     [0] => array         (             [0] => boxer1.jpg         )      [1] => array         (         [0] => boxer2.jpg         )     ) 

$id1

array ( [0] => array     (         [car_id] => 6         [alt_img] => boxer     ) 

)

i trying merge them create new array $pix final should this:

array(      array( 'car_id' => '6', 'pic_lg' => 'boxer1.jpg', 'alt_img' =>       'boxer'),      array( 'car_id' => '6', 'pic_lg' => 'boxer2.jpg', 'alt_img' =>       'boxer'),      etc... 

thank you.

based on informations, approach:

$pix = array(); ($i=0; $i<count($id1);$i++) {      $pix[$i]  = $id[$i];     $pix[$i]['pic_lg'] = $pictures1[$i][0];  } var_dump($pix); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -