如何从这个数组中返回单个元素


how can i echo individual elements from this array

我有一个使用PDO::FETCH_OBJ从数据库查询中获得的array。它包含用户对某些帖子的评论,我需要echo每个单独的值。我如何从这个array中获得元素值?

Array ( [0] => stdClass Object ( [posts] => lo;l;l ) [1] => stdClass Object ( [posts] => i am feeling well ! ) [2] => stdClass Object ( [posts] => it's 8 am in the morning .... ) [3] => stdClass Object ( [posts] => i am new here :) ) [4] => stdClass Object ( [posts] => farewell day !!!! ) [5] => stdClass Object ( [posts] => farewell day !!!! ) [6] => stdClass Object ( [posts] => farewell day !!!! ) [7] => stdClass Object ( [posts] => farewell day !!!! ) [8] => stdClass Object ( [posts] => bal ) [9] => stdClass Object ( [posts] => bal ) [10] => stdClass Object ( [posts] => halum ) ) 
foreach($array as $key => $val){
     echo $val->posts;
}