Accessing variable of stdClass in Smarty array
Posted: Wed May 12, 2010 8:59 pm
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.
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.