Re: [SMARTY] array starting at index 1

From: Date: Fri, 07 Nov 2003 22:21:19 +0000
Subject: Re: [SMARTY] array starting at index 1
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10510@lists.php.net to get a copy of this message
On Fri, Nov 07, 2003 at 02:10:02PM -0800, Chadwick, Russell wrote: > > Hello all, I tried quite a few approaches to this. Hopefully someone can help me > > I am trying to iterate through a multidimensional array and the first element is index 1 > instead of the usual 0. When I set the start=1 it causes it to not display the last item, meaning > $edits[4] in this case. I tried using a foreach also, no luck. > > Thanks for your help - Russ > > This is my template: > > {section name=edit start=1 loop=$edits} > <tr class="table_{cycle values="odd,even"}_row"> > <td>{$edits[edit].title}</td> > </tr> > {/section} {foreach item=edit from=$edits} <tr class="table_{cycle values="odd,even"}_row"> <td>{$edit.title}</td> </tr> {/foreach} [section} works only for zero-based arrays. > Where edits is assigned to this: > > Array > ( > [1] => Array > ( > [title] => Map ID > ) > [2] => Array > ( > [title] => Tile ID > ) > [3] => Array > ( > [title] => X Coord > ) > [4] => Array > ( > [title] => Y Coord > ) > )

« previous php.smarty.general (#10510) next »