Accessing variable of stdClass in Smarty array

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
gap_tooth_clan

Accessing variable of stdClass in Smarty array

Post by gap_tooth_clan »

I have spent several hours stressing out, trying to get a variable out of an array or stdClass objects. I could have looped through the array to find what I wanted but it just seemed a terrible way to do things.

My array looked like this when I did a print_r:

array
(
    [0] => stdClass Object (
        [id] = 1
        [name] = example
    )
)

I thought you would access the variable like $myarray[0]->id

But this did not work, my mistake is that you need to do it like this $myarray[0][0]->id

Hope this can save you some time.
Post Reply

Return to “Tips and Tricks”