Hello,
I was trying to create 2 arrays using a form:
HTML:
<input type="text" name="textfield[]"><br>
<input type="text" name="textfield[]"><br>
<input type="text" name="textfield2[]"><br>
<input type="text" name="textfield2[]"><br>
and it works fine except that when I am trying to go through them I want to work on them together. If I work on them one at a time I can do:
PHP:
foreach ($_POST['textfield'] as $textfield) { echo ($textfield); }
But if I am trying to do it with 2 fields then it gets hinky. You can't step through them using the FOREACH function anymore. I tried to just use a FOR function to step through them:
PHP:
for ($x=0; $x<4; $x++) {
echo ($_POST['textfield[$x]']);
}
But that will not produce any data. So then I tried to just reassign the POST array using the FOREACH function:
PHP:
foreach ($_POST['textfield'] as $textfield)
Now this almost works as if you then do prints using $textfield and a loop there is data. The problem is for some reason there is 2 copies of each piece of data. So if there were 4 entries, it will be 8 entries.
Thanks for any help that can be provided.
- Aludaan