Variable scope in foreach?
| From: | Matthew Hagerty | Date: | Mon, 31 Mar 2003 17:20:19 +0000 |
| Subject: | Variable scope in foreach? | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-1057@lists.php.net to get a copy of this message | ||
Greetings,
Does Smarty have local variable scope within foreach blocks? In this
example, $depth1_count always shows up as 0 (zero). Any insight would be
greatly appreciated. I'm using Smarty 2.4.2.
Thanks,
Matthew
{counter name="depth1" start="0" print=false}
{foreach from=$array1 item=aSubArray}
{counter name="depth1" assign="depth1_count"}
{counter name="depth2" start="0" print=false}
{foreach from=$aSubArray.items item=aItems}
{$depth1_count}.{counter name="depth2"} {$aItems.title}
<br />
{/foreach}
{/foreach}