Re: [SMARTY] array starting at index 1

From: Date: Fri, 07 Nov 2003 22:17:35 +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-10509@lists.php.net to get a copy of this message
Fixing the problem, always start your array indexes at zero. Fixing the symptom, use {foreach} to loop over your array instead of {section} Monte On Fri, 2003-11-07 at 16:10, 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} > > 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 (#10509) next »