2012-07-30 216 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