1

php isn't really my thing but I would need to get the votes and percentage from votes array.

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.

No need to loop it or something?

2 Answers 2

4

You need to change some object attribute access notation to array access notation:

$items->votes['plus']['points']['votes']
Sign up to request clarification or add additional context in comments.

1 Comment

Well yes of course. My brain must have been frozen before. Thx alot!
1

You will have to access the array elements by key, something like this:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.