|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
rubyaryat Smarty Rookie
Joined: 24 Apr 2003 Posts: 6
|
Posted: Thu May 01, 2003 1:01 am Post subject: Specifying index of an array |
|
|
I'm looping thru and array and wish to access a element relative to the index.
i.e. wish to use something like:
$arrayname[arrayindex+1].Number
Anyone know how to do this? |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Thu May 01, 2003 1:50 am Post subject: |
|
|
http://smarty.php.net/manual/en/section.property.index.php _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu May 01, 2003 2:28 am Post subject: |
|
|
I think AZTEK is just funning you.
[arrayindex+1] won't work as there is no native math available in smarty. For math, you have to use the (slow) math plugin.
Try this:
$arrayname[arrayindex.index_next].Number
http://smarty.php.net/manual/en/section.property.index.next.php |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Thu May 01, 2003 3:02 am Post subject: |
|
|
Always a page short BTW I am really looking forward to native math in Smarty _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Thu May 01, 2003 12:25 pm Post subject: |
|
|
yeah... me too... actually, {math...} stuff is the only thing in Smarty I don't like... I'd need things like {$foo-1} quite often... |
|
Back to top |
|
rubyaryat Smarty Rookie
Joined: 24 Apr 2003 Posts: 6
|
Posted: Thu May 01, 2003 3:35 pm Post subject: |
|
|
Must have skipped that part of the doc...
Experimenting with index_prev, index and index_next to create a three column table.
What I want the following table to create is:
0 1 2
3 4 5
What I get is:
-2 1 4
1 4 7
<table>
{section name=oi loop=$orders_data1 start=1 step=3}
<tr>
<td width=252>
{$smarty.section.oi.index_prev}
</td>
<td width=252>
{$smarty.section.oi.index}
</td>
<td width=252>
{$smarty.section.oi.index_next}
</td>
</tr>
{/section}
</table> |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|