使用foreach循环获取stdClass对象中的计数值

时间:2012-04-04 12:13:37

标签: php arrays

Array ( [0] => stdClass Object ( [count] => 3  ) ) 
Array ( [0] => stdClass Object ( [count] => 1 ) ) 
Array ( [0] => stdClass Object ( [count] => 2 ) )
Array ( [0] => stdClass Object ( [count] => 0 ) )
Array ( [0] => stdClass Object ( [count] => 0 )  ) 
Array ( [0] => stdClass Object ( [count] => 0 )  )
Array ( [0] => stdClass Object ( [count] => 0 )  )
Array ( [0] => stdClass Object ( [count] => 3 )  ) 

我想只打印3 1 2 0 0 0 0 3

1 个答案:

答案 0 :(得分:2)

foreach($data as $array)
{
   echo $array[0]->count;
}