2

I do create a quizz where the questions are created dynamically, so I can't really know how much answsers the javascript is going to generate.

Sending the data through Ajax is not the problem, but when it came to the PHP I would like to get the data from the form and I'm used to do it with the $POST['toto']... But I don't know the id (names) of the inputs.

I thought 2 solutions, Create one field each time containing the number of answers. Or using a cookie so i could do a loop in the php file...

Is there any better solution?

Thank you goldiman

goldiman
  • 189
  • 2
  • 13

1 Answers1

4

$_POST is an array. You can iterate through each value

foreach ($_POST as $key => $value) {
    $value; // one of the quiz answer
}
leopik
  • 2,323
  • 2
  • 17
  • 29