对于这个数组
stdClass Object
(
[YearsResult] => stdClass Object
(
[years] => stdClass Object
(
[year] => Array
(
[0] => 2013
[1] => 2012
[2] => 2011
[3] => 2010
[4] => 2009
[5] => 2008
[6] => 2007
[7] => 2006
[8] => 2005
[9] => 2004
[10] => 2003
[11] => 2002
[12] => 2001
[13] => 2000
[14] => 1999
[15] => 1998
)
)
)
)
运行foreach循环以获取年份值的正确方法是什么?我已经尝试了所有可以想到的方法,我可以找到/想到,我的最后一次尝试是
foreach ($result->YearsResult->years->year as $test) {
echo $test->year;
}
不返回任何内容。
答案 0 :(得分:0)
$ result-> YearsResult-> years-> year是您想要的数组。所以$ test是数组元素。
echo $test;