PHP will organize form values into arrays if you ask nicely
I took stole this example directly from php.net but it is worth the infraction. Name your form fields correctly and they are placed in arrays in the $_GET or $_POST arrays. This example would return something like this if you selected two of the "beer" elements.
Array
(
[personal] => Array
(
[name] => Fred Derf
[email] => fred@example.com
)
[beer] => Array
(
[0] => warthog
[1] => guinness
)
)
Array
(
[personal] => Array
(
[name] => Fred Derf
[email] => fred@example.com
)
[beer] => Array
(
[0] => warthog
[1] => guinness
)
)
<?php if ($_POST) { echo '<pre>'; echo htmlspecialchars(print_r($_POST, true)); echo '</pre>'; } ?> <form action="" method="post"> Name: <input type="text" name="personal[name]" /><br /> Email: <input type="text" name="personal[email]" /><br /> Beer: <br /> <select multiple name="beer[]"> <option value="warthog">Warthog</option> <option value="guinness">Guinness</option> <option value="stuttgarter">Stuttgarter Schwabenbräu</option> </select><br /> <input type="submit" value="submit me!" /> </form>