Associative arrays and keys as foreach items

From: Date: Wed, 18 Dec 2002 11:51:05 +0000
Subject: Associative arrays and keys as foreach items
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6872@lists.php.net to get a copy of this message
Hello all, I have two variables assign from PHP: $categories and $images; $categories is an array of arrays, each sub-array is indexed by two keys:'id' and 'name'; $images is an array of arrays, too, each sub-array being indexed by 'id' and 'src'. Now, I'm trying to do something like this: {* index.tpl *} {* all the HTML code is stripped *} {foreach from=$categories item=cat} {foreach from=$images.$cat.id item=image} {* bla bla do something with the data *} {/foreach} {/foreach} {* end of index.tpl *} Well, (as you would have probably expected) it doesn't work. Why? Are there any viables alternatives? Like, if I assign $cat.id to say $cat_id (from inside the Smarty template), it works, but I don't want that. Thanks in advance, Radu

« previous php.smarty.general (#6872) next »