我有一个看起来像这样并存储在变量中的数组对象$named_array
Array
(
[results] => Array
(
[0] => Array
(
[date] => 2013-15-6
[position] => 5
[person] => John
)
[1] => Array
(
[date] => 2013-15-6
[position] => 3
[person] => Alex
)
)
)
另一个名为的数组$post
是一个名为 WordPress 的 post 对象数组,$posts = get_posts(array(....
然后我有一个 foreach 每个循环,其中 $post 是变量。
在我的 foreach 循环中,我尝试了以下方法来组合数组,但它不起作用。
$combinedData = array_merge($post, $named_array);
print_r($combinedData);
我可以使用 print_r($post); 查看我的帖子对象数组 在 foreach 循环以及 named_array 中。将 named_array 添加到 post 数组的正确函数是什么?
谢谢