Forum Moderators: coopster

Message Too Old, No Replies

foreach and form array

         

webnoob

6:14 pm on May 3, 2005 (gmt 0)

10+ Year Member



i have two input text fields and file fields and want to loop it, it should loop in pairs, probably describing it poorly.. hope someone understands.

i have something like this:

1: <input type="file" name="info[attachment][]">
2: <input type="text" name="info[filecaption][]">

1: <input type="file" name="info[attachment][]">
2: <input type="text" name="info[filecaption][]">

how do i foreach it so when POSTED attachment and filecaption are in the same array?

jatar_k

9:18 pm on May 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I usually start by looking at the POST array to understand what exactly my data looks like with

echo '<pre>';
print_r($_POST);
echo '</pre>';

I can then actually look at the array and data to see how it is structured. I make an attempt on the same page to loop it, then look at the data and my loop results to see how I screwed it up. ;)

see if that helps you see the pattern.