Objects with associative arrays
| From: | Tryggvi T. Hjörvar | Date: | Mon, 28 Apr 2003 01:46:56 +0000 |
| Subject: | Objects with associative arrays | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-9396@lists.php.net to get a copy of this message | ||
Hi
I haven't been able to find anything in the docs to help me with the following problem. Maybe I am just confused, but I would appreciate some feedback anyway...
I have an object (let's call it "book") that has an associative array ("arrRole") as a member variable. So I assigned (not registered, as per the docs) the object to the template, and wanted to do something like this, to loop over all the items in the array:
{section name=role loop=$book->arrRole.create}
{$book->arrRole.read[role]}
{$book->arrRole.write[role]}
{/section}
This results in: *Fatal error*: Call to undefined function: ()
To simplify, even just echoing one item doesn't work:
{$book->arrRole.read[0]}
In desperation I then tried
{$book.arrRole.read[0]}
which does not cause an error, but prints nothing at all.
Thanks in advance
Tryggvi