A function returns array of following type:
Array ( [0] => stdClass Object ( [post_id] => 48
I want to echo the array contents, so i tried using following foreach loop:
foreach ($posts as $post){
echo $post['post_id'];
}
But I get following error:
Fatal error: Cannot use object of type stdClass as array in
You have an array of objects. So, you need to change:
To:
Now, you’re printing the object property
post_id.