This form submits the selected options to mypage.php to get processed.
If you were to attempt to acces the values in mypage.php like so:
The display would be
The word "Array" is the only thing that would be output. This would be consistent with the fact that there were several items passed, however if you were to access the variable as an array, as would be logical to do so:
Notice: Uninitialized string offset: 1 in mypage.php on line 37
Notice: Uninitialized string offset: 2 in mypage.php on line 38
Why does this happen?
This is because of the way the values get sent to PHP.
When the form is submitted the browser sends:
however since there are more choices it continues to assing values:
This effectively overwrites the previous value that was assigned to $options.
In order to get every option that was selected you need to add a pair of brackets at the end of the Select box's name like so:
<SELECT multiple name="options">
The brackets tell PHP that the submitted data is in actuality an Array.
So instead of overwriting the values that get sent, they get added to subsequent positions in the array.
This will now allow us to access every value that was selected, from the array.