$_POST variable - Looping through numbered arguments

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smcallister
Forum Newbie
Posts: 2
Joined: Fri May 23, 2008 9:48 am

$_POST variable - Looping through numbered arguments

Post 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++;
}
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: $_POST variable - Looping through numbered arguments

Post by jaoudestudios »

Do you mean something like this...

Code: Select all

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