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
Post a Comment