I need to write PHP code to handle a form. The form may have zero or more fields that are named "recipient1", "recipient2", "recipient3", etc. If there are two fields, I need to capture those fields. If there are six, I need to capture all six. Maybe there are none.
I could write
if (isset($_POST['recipient1'])) {
$thisvariable1=$_POST['recipient1'];
}
if (isset($_POST['recipient2'])) {
$thisvariable2=$_POST['recipient2'];
}
if . . . and so on. Maybe I could do 10 of these, but what if the form has 11 fields (recipient1 through recipient11)? I can't just write a hundred "if" statements. Surely there's some way to write a code that allows me to replace the "1", "2", and so on with some variable.
The form itself will pass along how many fields there are. How can I use that number to automatically generate this kind of code that assigns the $_POST data to variables?
Does that make more sense? How can I do this? That's my question.