I have a form with multiple input fields that are named using an id. I am appending the id to the field name so that they are unique. For example:
<select name="values_1[]" multiple="">
<option>1</option>
<option>2</option>
</select>
<select name="values_2[]" multiple="">
<option>1</option>
<option>2</option>
</select>
How can I iterate through just these fields in my controller to extract the values selected?
CodePudding user response:
<select name="values[{{ $id }}]" multiple="">
<option>1</option>
<option>2</option>
</select>
foreach($request->get('values') as $value) {
}
CodePudding user response:
you can use foreach :
foreach(values_1 as value1){
// do something
}
foreach(values_2 as value2){
// do something
}