Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-参考数组中的stdclass对象_Php_Arrays_Stdclass - Fatal编程技术网

PHP-参考数组中的stdclass对象

PHP-参考数组中的stdclass对象,php,arrays,stdclass,Php,Arrays,Stdclass,上下文 我试图参考下面的值: Array ( [0] => stdClass Object ( [label] => John Smith [attributes] => Array ( [class] => sf-level-0 sf-item-14 ) [value] => smith-john [depth] => 0 [cou

上下文

我试图参考下面的

Array (
    [0] => stdClass Object (
        [label] => John Smith
        [attributes] => Array (
            [class] => sf-level-0 sf-item-14
        )
        [value] => smith-john
        [depth] => 0
        [count] => 3
    )
    [1] =>... etc.
问题


假设数组名为$array,那么正确的格式是什么?我尝试了
array[0]->['value']
,但它不起作用。

很难说你的格式。但是:

$array[0]->value
数组中的第一个元素的类型为
stdClass Object
,因此要访问其成员,请使用对象访问器
->
,而不是数组语法


注:马克的编辑使内容清晰易读,这是他应得的荣誉。

你的格式很难说。但是:

$array[0]->value
数组中的第一个元素的类型为
stdClass Object
,因此要访问其成员,请使用对象访问器
->
,而不是数组语法


PS:马克用他的编辑使东西清晰易读,这是他应得的荣誉。

$array[0]>值应该是您所需要的。你忘了
$
?我有
$
-也把它加在这里了。这是成功的,谢谢你的回答和修改$数组[0]->值应该是您所需要的。你忘了
$
?我有
$
-也把它加在这里了。这是成功的,谢谢你的回答和修改!太好了,谢谢!太好了,谢谢!