I have a smarty template where a plugin loads an array for me. This array contains some elments which themselves are arrays of stdClass objects, and other elements which are simply stdClass objects. For instance, I might have
Array
(
[0] => Array
(
[0] => stdClass Object
(
[id] => 1
[avatar_file] => joey_thumb.jpg
[group] => 0
[order_in_group] => 0
)
[1] => stdClass Object
(
[id] => 2
[avatar_file] => christy_thumb.jpg
[group] => 0
[order_in_group] => 1
)
)
[1] => stdClass Object
(
[id] => 11
[avatar_file] => angela_thumb.jpg
[group] =>
[order_in_group] =>
)
)
In my template, I have something to the effect of:
{foreach from=$membersArray item=memberOrGroup}
{if is_array($memberOrGroup)}
<div>{$memberOrGroup[0].id}</div>
{else}
<div>{$memberOrGroup.id}</div>
{/if}
{/foreach}
But as soon as it hits any normal replacement like in my div tags above that has an array reference like $memberOrGroup[0], I get the error "Cannot use object of type stdClass as array". I'm sort of at my whit's end, since I can print_r the original array and it shows the elements layed out like above. I can even print_r inside the "is_array" if block using {$memberOrGroup[0]|print)r} and it prints out an stdClass object populated with the right data and doesn't give me an error.
I've seen several solutions on the web that show using nested foreach loops, but in the real version of my loop each element of the second dimension array has to be placed in a certain spot (as in $memberOrGroup[0] has a special place, and so does $memberOrGroup[1]).
I've tried several variations including using sections instead, but I still come down to the same error.