Page 1 of 1

$_POST variable - Looping through numbered arguments

Posted: Thu Dec 11, 2008 1:36 pm
by smcallister
I have a list of 20 radio buttons, named "1", "2", "3"... "20" that are being submitted via a php form and the POST method.

When I capture the variables, I want to be able to execute a while loop that will print out all the values selected by the radio buttons... only I don't want to explicitly define all of them. I want to run something like this:

while ($loop < $count)
{
print $_POST[$loop];
$loop++;
}

Re: $_POST variable - Looping through numbered arguments

Posted: Thu Dec 11, 2008 2:00 pm
by jaoudestudios
Do you mean something like this...

Code: Select all

 
foreach ($POST AS $k=>$v) {
    echo $k." --- ".$v;
}