Hello,
I have a html form which has a dynamic number of fields, each with a dynamic name.
I am passing the amount of fields and an array containing the field names as hidden form fields when the user submits the form.
This is OK.
The function which receives my array (receives the $POST['array_of_form_names']) when the user submits the form... how do I populate an array with the $POST['array_of_form_names'] ?
I am currently doing this -
function get_array(&$formfields)
{
$formfields = array();
$formfields = $_POST['array_of_form_names'];
}
After this I would expect the array $formfields to have all the values of $_POST['array_of_form_names'], right?
Well, if I loop as follows -
for ($i =0; $i<$number_of_array_fields; $i++)
echo $formfields[$i];
Am I doing something wrong? Can arrays not be passed BY REFERENCE? I need to keep $formfields after the function ends, hence the by reference requirement. Also, am I assigning the form array to my $formfields array incorrectly?
Any pointers appreciated...
Thanks!