2012-07-30 272 views
1

PHP新手....我试图从解码的json文件中访问数组中的值。我印我的变量在屏幕上,这被退回......访问stdClass对象数组

Array ( 
[0] => stdClass Object ( 
    [period] => 0 
    [title] => Sunday 
    [fcttext] => Mostly cloudy with a chance of ... 
    [pop] => 50) 
[1] => stdClass Object ( 
    [period] => 1 
    [title] => Sunday Night 
    [fcttext] => Partly cloudy. Low of 64F. Win.... 
    [pop] => 10) 
[2] => stdClass Object ( 
    [period] => 2 
    [title] => Monday 
    [fcttext] => Partly cloudy. High of 90F. Winds less than 5 mph. 
    [pop] => 10) 
[3] => stdClass Object ( 
    [period] => 3 
    ... 
    ) 
) 

如何访问,例如,在fcttext从周期1?

谢谢!

回答

0

类的方法和properties->运营商访问:

echo $arr[1]->fcttext; 

退房Reference - What does this symbol mean in PHP?当你在PHP中操作的含义不确定。

+0

那很简单。非常感谢! – pigishpig 2012-07-30 01:53:16

+0

@pigishpig没问题。欢迎来到SO。社区的一个重要组成部分是投票表明好的或坏的答案的质量和标记已解决。当您标记为已解决时,它不仅向社区表明了这一点,而且也正面反映了您的接受比例。欲了解更多信息,请参阅http://stackoverflow.com/faq#howtoask并询问您是否有任何问题! – 2012-07-30 03:19:31