|
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 |
glynnyth Smarty n00b
Joined: 18 Sep 2006 Posts: 1
|
Posted: Mon Sep 18, 2006 2:47 pm Post subject: Looping over multiple multidimensional associative arrays |
|
|
{foreach}: only for single array (says manual), non-numeric arrays allowed at every level (i.e. associative arrays of associative arrays)
{section}: iteration over multiple arrays, but non-numeric arrays only allowed at lowest level (i.e. indexed arrays of associative array)
How to iterate over multiple multidimensional associative arrays of associative arrays?
$test = array("foo"=>array("AA"=>array("bel"=>0, "eur"=>1, "europ"=>2, "am"=>3,"az"=>4,"glob"=>5)));
$test2 = array("foo"=>array("AA"=>array("bel"=>0, "eur"=>1, "europ"=>2, "am"=>3,"az"=>4,"glob"=>5)));
***
{foreach from=$test key=key item=item}
Array1: {$stats.AA.am} = {$test.$key.AA.am}
Array2: {$test2.$key.AA.am}
{/foreach}
'item' is not used but required by Smarty
keys of arrays need to be the same |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Sep 18, 2006 4:39 pm Post subject: |
|
|
Code: | {foreach from=$test key="key1" item="val1"}
{foreach from=$val1 key="key2" item="val2"}
{foreach from=$val2 key="key3" item="val3"}
...
{/foreach}
{/foreach}
{/foreach} |
|
|
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
|