Smarty, associative arrays and underscores not playing nicely
| From: | Duncan Hill | Date: | Sat, 11 Oct 2003 10:31:38 +0000 |
| Subject: | Smarty, associative arrays and underscores not playing nicely | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10335@lists.php.net to get a copy of this message | ||
I've been having great 'fun' with Smarty, associative arrays and briefly,
sections.
I have a subroutine that returns an associative array that's keyed by strings,
not numeric indices. The general structure of the array is:
$data = array('key' => array('reccount' => '2',
'value_1' => 'Foo', 'value_2'
=> 'Bar' ));
$sm->assign('data', $data);
My smarty code looks like:
{$data.key.reccount}
{$data.key.value_1}
The first statement prints '2'. Perfect.
The second statement prints.. nothing.
Are underscores taboo or something in Smarty?
(I tried the following with no success as well, does section require numeric
indices?
{section name=row loop="$data"}
{$data[row].value_1}
{/section}
I expected that to get a value of 'key' for row, and print out 'Foo'. But it
didn't.)
I've tried Smarty 2.5, and 2.6RC2 now.