I am processing a form that will receive lots of elements through $_POST. A certain number of these (too large a number to write out manually) follows a pattern:
$_POST['city_1']
$_POST['city_2']
$_POST['city_3']
$_POST['city_4']
etc.
The way the form is set up, I’m not sure how many elements like this are going to be sent over — it could be one, it could be 50. How can I process just a few of the $_POST elements based on their names?
You should create a multidimensional array instead.
Your HTML form fields could look like this:
In your PHP code you can then loop through your cities by accessing
$_POST['cities']: