1

PHP 新手....我正在尝试访问来自解码的 json 文件的数组中的值。我将变量打印到屏幕上,然后返回...

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
    ...
    ) 
) 

例如,我如何访问第 1 期的 fcttext?

谢谢!

4

1 回答 1

0

类方法和属性通过->操作符访问:

echo $arr[1]->fcttext;

查看参考 - 这个符号在 PHP 中是什么意思?当您不确定 php 中运算符的含义时。

于 2012-07-30T01:52:15.243 回答