|
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 |
S_aIN_t Smarty n00b
Joined: 01 Jun 2003 Posts: 2
|
Posted: Sun Jun 01, 2003 3:14 am Post subject: print index of array? |
|
|
i have been slowly workign with smarty for about a week. but after reading most of the docs and searching the forums, i cannot see an obvious way to print out the index of an array:
so, how do i do the equivalent of this:
Code: |
for(int i = 0; i <= array.size(); i++) {
print i + " = " array[i];
}
|
i can get the date out of the array, but not the index at which it is located.
thanks |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Jun 01, 2003 4:13 am Post subject: |
|
|
Hi S_aIN_t.
Code: | {section name=test loop=$arr}
{$smarty.section.test.index} : {$arr[test]}
{/section} |
Manual Entries:
There are also many threads on this forum concerning looping, recursion and uses of {section} and {foreach} and even custom function blocks as iterators.
Good luck! |
|
Back to top |
|
S_aIN_t Smarty n00b
Joined: 01 Jun 2003 Posts: 2
|
Posted: Sun Jun 01, 2003 6:06 pm Post subject: |
|
|
ahh.. .thanks.. i will look more carefully next time. |
|
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
|