|
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 |
masdel1979 Smarty n00b
Joined: 02 Mar 2017 Posts: 2
|
Posted: Thu Mar 02, 2017 4:30 pm Post subject: How to read dynamic array in to foreach (Smarty 2) |
|
|
Hi all,
my name is Massimilian and this is my first post..
I want to read dynamically this array (Smarty 2):
test.red_0
test.yellow_0
test.green_0
test.red_1
test.yellow_1
test.green_1
......
test.red_n
test.yellow_n
test.green_n
What is the best way to do?
I tried a different solution, but not work, for example this (i know the number of items, 0 to 29):
Code: |
{section name=count loop=30 start=0 step=1 max=29}
{assign var=test_red value=$test.red_`$smarty.section.count.index`}
{assign var=test_yellow value=$test.yellow_`$smarty.section.count.index`}
{assign var=test_green value=$test.green_`$smarty.section.count.index`}
{$test_red}, {$test_yellow}, {$test_green}<br/>
{/section} |
and the result is:
Code: | Array.red_0, Array.yellow_0, Array.green_0
Array.red_1, Array.yellow_1, Array.green_1
....
Array.red_n, Array.yellow_n, Array.green_n |
Can you help me, please?
Regards Massimiliano |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Mar 02, 2017 5:53 pm Post subject: |
|
|
Fix your array and you won't need this retarded construct in first place.
PHP supports multi-dimensional arrays just fine. |
|
Back to top |
|
masdel1979 Smarty n00b
Joined: 02 Mar 2017 Posts: 2
|
Posted: Fri Mar 03, 2017 8:26 am Post subject: |
|
|
AnrDaemon wrote: | Fix your array and you won't need this retarded construct in first place.
PHP supports multi-dimensional arrays just fine. |
Hi AnrDaemon,
This is the best solution, but unfortunately it's not possible to fix the Array...
Don't exist any way in Smarty?
Regards Max |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Mar 03, 2017 1:21 pm Post subject: |
|
|
Fix. Your. Array. |
|
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
|