我怎样才能回应这个数组中的各个元素

时间:2015-10-08 12:09:18

标签: php arrays pdo stdclass

我有array我使用PDO::FETCH_OBJ从数据库查询中获得。它包含用户对某些帖子的评论我需要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 ) ) 

1 个答案:

答案 0 :(得分:0)

foreach($array as $key => $val){

     echo $val->posts;

}
相关问题