1

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?

John Smith
  • 6,129
  • 12
  • 68
  • 123

1 Answers1

1

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

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291