【问题标题】:how can i echo individual elements from this array我如何从这个数组中回显单个元素
【发布时间】:2016-01-06 01:13:25
【问题描述】:

我有一个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 ) ) 

【问题讨论】:

    标签: php arrays pdo stdclass


    【解决方案1】:
    foreach($array as $key => $val){
    
         echo $val->posts;
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-22
      • 2017-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-19
      • 1970-01-01
      • 2012-04-27
      相关资源
      最近更新 更多