Reputation: 6197
Im debugging a variable:
{foreach from=$menuItems item=row}
{$row|@print_r}
{/foreach}
this prints
Array ([parent_id] => 0) 1 Array ( [parent_id] => 5)
so far so good. I have to iterate it, but
{foreach from=$menuItems item=row}
{$row.parent_id|@print_r}
{/foreach}
01 51 01
seems too add an unnecessary number "1" after the number. Wtf?
Upvotes: 1
Views: 46
Reputation: 111839
I've checked it.
In PHP I have:
$name = array();
$name[] = array('parent_id' => 0);
$name[] = array('parent_id' => 5);
$smarty->assign('menuItems',$name);
In Smarty I have:
{foreach from=$menuItems item=row}
{$row|@print_r}
{/foreach}
<br />
{foreach from=$menuItems item=row}
{$row.parent_id|@print_r}
{/foreach}
Output is:
Array ( [parent_id] => 0 ) 1 Array ( [parent_id] => 5 ) 1
01 51
So it works as exepcted. I've tested it in Smarty 3.1.18. Probably there was some bug in earlier version. There are quite many fixed from that time - https://code.google.com/p/smarty-php/source/browse/trunk/distribution/change_log.txt
Upvotes: 1