Add array object to array php? -
i have array object looks , stored in variable $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 ) ) )
another array called $post
wordpress post object array called $posts = get_posts(array(....
have foreach each loop $post being variable.
within foreach loop i've tried following combine arrays it's not working.
$combineddata = array_merge($post, $named_array); print_r($combineddata);
i can see post object arrays print_r($post); within foreach loop named_array. what's correct function add named_array post array?
thanks
$posts
mentioned, array of objects
$post
object, not array, can't use array_merge()
if want add results new property $post
, correct way is:
$post->results = $named_array['results'];
Comments
Post a Comment