This is a discussion on Smarty PHP section looping problem within the PHP General forums, part of the PHP Programming Forums category; Hi, I'm implementing smarty and I am trying to loop through some arrays. I have this piece of code ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I'm implementing smarty and I am trying to loop through some arrays. I have this piece of code in a template: {foreach key=outer_number item=out from=$outer} <b> {$out.id}</b> <br> {section name=inner_number loop=$inner[$out.id]} {$inner[$out.id][inner_number].name} <br> {/section} {/foreach} which once the arrays are filled produces: 7618 7617 7616 7615 As you can see the code is looping through the outer array, displaying the id but never gets into the inner array using $out.id. For de-bugging purposes I have hard-coded $out.id with 7618 (one of the displayed $out.id's) the code now looks like: {foreach key=outer_number item=out from=$outer} <b> {$out.id}</b> <br> {section name=inner_number loop=$inner[7618]} {$inner[7618][inner_number].name} <br> {/section} {/foreach} which produces: 7618 Goodwin Montgomerie Cottey Adams Ambrose Martin-Jenkins Prior Davis Kirtley Lewry 7617 Goodwin Montgomerie Cottey Adams Ambrose Martin-Jenkins etc etc The code is now looping through the outer array and the inner array. Can anyone suggest how I can get the code to properly use $out.id inside the inner loop? Thanks |