Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Specifying index of an array

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
rubyaryat
Smarty Rookie


Joined: 24 Apr 2003
Posts: 6

PostPosted: Thu May 01, 2003 1:01 am    Post subject: Specifying index of an array Reply with quote

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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Thu May 01, 2003 1:50 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 01, 2003 2:28 am    Post subject: Reply with quote

I think AZTEK is just funning you. Wink

[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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Thu May 01, 2003 3:02 am    Post subject: Reply with quote

Always a page short Smile 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
View user's profile Send private message Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Thu May 01, 2003 12:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
rubyaryat
Smarty Rookie


Joined: 24 Apr 2003
Posts: 6

PostPosted: Thu May 01, 2003 3:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP