Might seem like a stupid question, but I’m having an issue creating an array from multiple POST variables. They are coming from a jQuery form that can have any number of variables. It can be 1 of 2 options, name or school.
For example: $_POST['name1'], $_POST['school2'], $_POST['name3'], $_POST['name4'], etc.
Is there a way to get the max number of variables and put each variable into an array? Or is there a better way of doing this?
Any input is appreciated.
Is that what you mean? PHP Form Arrays Then, reference wise, you now have an array for
$_POST['name']and$_POST['school']Alternatively, if you’re numbering them you can use a foreach on the $_POST variable: