I got my multiple select fields:
<select name="cars[]" id="cars" multiple="multiple">
<option value="yellow">Yellow</option>
<option value="black">Black</option>
[..]
</select>
and this one:
<select name="cars[]" id="cars" multiple="multiple">
<option value="audi">Audi</option>
<option value="volk">Volkswagen</option>
[..]
</select>
when I select a random options and submit the form, do the print_r on the $_POST the output is:
[group] => Array
(
[0] => audi
[1] => volk
[2] => black
)
I want to access the color now (it that case it would be the key no. 2 from the array), but the problem is that it may change, when I select other fields, eg. I select one car brand and one color… when then it looks like:
[group] => Array
(
[0] => audi
[1] => yellow
)
So the question is: Is there any way to always access the selected cars colour and cars brand? It would be nice if it would be separated, but its not and the array key is changeable.
Just use different names (+ duplicate
idis illegal and may cause problems)