Share » Forums » Setup & design » Initialize a hash and add items to it

Initialize a hash and add items to it

Initialize a hash and add items to it

Saturday 02 December 2006 2:18:54 am - 1 reply

Author Message

Claudia Kosny

Saturday 02 December 2006 3:02:40 am

Hi OOzy

{def $hash = hash('key1', 'value1')
     $keyArr = array('key2', 'key3', 'key4')
     $valueArr = array('value2', 'value3', 'value4')}
{foreach $keyArr as $cnt => $key}
 {set $hash = $hash|merge(hash($key, $valueArr[$cnt]))}
{/foreach}
{$hash|attribute('show')}

Does not look very efficient but it seems to be the only way.

Claudia

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu