3
I need to get values from a multiselect
<select id="opcoes" name="opcoes[]" class="select" multiple="multiple" size="5" data-required required="required">
<option value="opcao1">Opção 1</option>
<option value="opcao2">Opção 2</option>
<option value="opcao3">Opção 3</option>
I wonder how I can take the selected values and put in a php variable.
I’ve tried with $_POST['opcoes[]']
, but always returns null to me.
I don’t get it, you need the
colchetes
? in the answer says no but in the code they are :)– rray
@rray In the answer he refers to what he has tried as
$_POST['opcoes[]']
but actually there is no need for the use, being that$_POST['opcoes']
would already return the array.– Gabriel Rodrigues
Aaaaaah that brackets hehe, now I get it.
– rray
rray and Gabriel Rodrigues, obg for the help. They clarified what I needed. I used the brackets because I thought that when I picked more than one option in select, I would be working with an array, so I put it (I had also searched this and some search sources indicated the use of the bracket). vlw guys!
– Diego Souza