简体   繁体   English

从数组多数民众赞成在数组内部获取字符串

[英]Getting string from array thats inside of an array

php isn't really my thing but I would need to get the votes and percentage from votes array. php并不是我真正的事情,但是我需要从投票数组中获取投票和百分比。

stdClass Object
( 
[id] => 312
[type] => item-e
[votes] => Array
        (
            [plus] => Array
                (
                    [points] => Array
                        (
                            [votes] => 1
                            [percentage] => 100
                        )

                )

        )
)

I tried this: 我尝试了这个:

$items->votes->plus->points->votes

But I get "Object of class stdClass could not be converted to string" -error message. 但我收到“类stdClass的对象无法转换为字符串”的错误消息。

No need to loop it or something? 不需要循环它或什么?

您需要将一些对象属性访问符号更改为数组访问符号:

$items->votes['plus']['points']['votes']

您将必须通过键访问数组元素,如下所示:

 $items->votes['plus']['points']['votes'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM