У меня есть проблема, как слияние этого массива. может мне помочь?
Первый массив:
массив
(
[22] => Объект WP_Post
(
[ID] => 22
[post_author] => 1
)
[23] => Объект WP_Post
(
[ID] => 23
[post_author] => 1
)
)
Второй массив:
массив
(
[0] => Объект stdClass
(
[img_thumb] => small_duck.jpg
[img_full] => duck.jpg
)
[1] => Объект stdClass
(
[img_thumb] => small_fish.jpg
[img_full] => fish.jpg
)
)
Если OutPut:
массив
(
[22] => Объект WP_Post
(
[ID] => 22
[post_author] => 1
[img_thumb] => small_duck.jpg
[img_full] => duck.jpg
)
[23] => Объект WP_Post
(
[ID] => 23
[post_author] => 1
[img_thumb] => small_fish.jpg
[img_full] => fish.jpg
)
)
Ключ массива следует за первым массивом,
Это работает…
$first = array( 22 => array( 'ID' => 22, 'post_author' => 1 ), 23 => array( 'ID' => 23, 'post_author' => 1 ) ); $second = array( array( 'img_thumb' => 'small_duck.jpg', 'img_full' => 'duck.jpg' ), array( 'img_thumb' => 'small_fish.jpg', 'img_full' => 'fish.jpg' ) ); echo '<pre>'; var_dump($first); var_dump($second); $i=0; $should = array(); foreach ($first as $key => $arr) { if(isset($second[$i])) $arr = array_merge($arr,$second[$i]); $should[$key] = $arr; $i++; } var_dump($should);