What I'm trying to do is use a for loop to multiple similarly named variables from a form into an array. Here is the relevant line of code I have that is not working:
$varName[ $counter ] = $_REQUEST[ 'varName' [$counter] ];
well, i can see why this code can't loop through an array. as stated above, php already puts your form variables into an array for you, so you shouldn't have to do it. but, if you wanted to loop through an array, you could use:
for ( $i = 0; $i <= $number_of_form_vars; $i++)
echo "$varName[$i];
but i don't think looping through the array is really the issue here. since the goal is to loop through an array so you do not have to declare them one at a time somewhere else in the code, i think the questions to ask would be:
how does php assign keys for form arrays? with numerical or non-numerical indexes? if non-numerical, does php use the 'name' attribute in the form to handle the form data? i really am not sure how it works. but, once it's understood how php assigns indexes to form array elements, it would be interesting to see if someone can declare them on an 'action' page with a loop.