Associative Array in a Primary Array Loop
| From: | Michael Caplan | Date: | Tue, 20 Nov 2001 23:15:21 +0000 |
| Subject: | Associative Array in a Primary Array Loop | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1992@lists.php.net to get a copy of this message | ||
Hi,
I've read through the docs, and done some preliminary research on this list,
but I am still unsure if Smarty can handle the following problem:
I am assigning a template two arrays:
$field -> a three dimensional array, where the third dimension is an
associative array that represents info on form elements
$add -> a two dimensional associative array which stores the results from
the submitted form
The two arrays are related by $field[key].name which is an "alias" for the
associative index of the $add array. I want to loop through the $field
array, and reference the values of the $add array on the way. What I worked
out follows. All is good, minus the $add array reference:
<{section name=key loop=$field}>
<input name="add[<{$field[key].name}>]"
type="<{$field[key].type}>"
size="<{$field[key].size|default:""}>"
maxlength="<{$field[key].size|default:""}>"
value="<{$add[$field[key].name]}>
<{/section}>
Is their a way to accomplish this?
As always - thank you,
Michael Caplan
Institute for Social Ecology
http://www.social-ecology.org/
1118 Maple Hill Road
Plainfield, VT, 05667 USA