Forums / Developer / hash :key not available with foreach

hash :key not available with foreach

Author Message

Bernhard Reiter

Wednesday 06 July 2005 2:21:22 am

This code works great with old template syntax.
But it seems like the key is no longer available when using foreach

{let hasharray=hash('key1','value1','key2','value2')}
<p> Hash array looping with a var:</p>
{section var=element loop=$hasharray}
key: <b>{$element.key}</b> value: <b>{$element}</b><br />
{/section}

Mikhail Chekanov

Wednesday 10 August 2005 4:11:15 am

Yes, it's not available. Keep it simple:

{foreach $hasharray as $key => $value}
key: {$key}, value: {$value}
{/foreach}

--
mike
#6595551