Hello,
I'm submitting an html form to a php script and want to assign values to variables in order to do a database update. I have always used this in the past with the $_POST array (in this case the array is coming fromTinyAjax):
foreach ($ary as $key => $value)
{
$$key = addslashes(trim($value));
}
This works as expected if all the $key names are unique. However the form has multiple rows (generated by php) as follows:
<tr><input name="code[0]" /><input name="description[0]" /></tr>
<tr><input name="code[1]" /><input name="description[1]" /></tr>
<tr><input name="code[2]" /><input name="description[2]" /></tr>
and so on. This produces an array like:
[code[0]] => OWNER
[code[1]] => MANAGER
and so on.
When I try to access the variable $code[0] it doesn't exist, but
echo "$key : $value"; gives code[0] : OWNER etc.
It seems as though the assignment of the value in the $$key = $value does not work for a key with an index[].
Has anyone any ideas what I'm doing wrong??
Thanks