that is means they are in Json format as array so just do something like this in your view :
<?php
$ss=json_decode($item->sf);
?>
@foreach
{{$ss}}
@Endforeach```
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello i have a form in wich i have some checkboxes, i intend to store from the form in the form of array,( but it's saving in phpmyadmin with square brackets and " " )like this: ["optionselected1","optionselected2"] when i try to fetch those values in a dashboard in a different page they dont appear, i got this code:
//create.blade
<div class="form-group mb-3">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="opt[]" value="opt1">opt1
</label>
</div>
<div class="form-group mb-3">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="opt[]" value="opt2">opt2
</label>
</div>
<div class="form-group mb-3">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="sf[]" value="opt1">opt1
</label>
</div>
<div class="form-group mb-3">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="sf[]" value="opt2">opt2
</label>
</div>
//controller
public function create(Request $request)
{
$opt= array($request->opt);
$sf = array($request->sf);
return view('admin.formulario.create', [
'viaturas' => Viaturas::all(),
'opt' => json_encode($opt),
'sf' => json_encode($sf),
]);
}
//store function
$data->opt= $request->input('opt');
$data->sf= $request->input('sf');
//and in fetch page
<tbody>
@foreach ($formulario as $item)
<tr>
<td>{{ $item->opt}}</td>
<td>{{ $item->sf}}</td>
how do i fetch correctly?? thanks in advance
you have not pass it correctly in foreach
@foreach($ss as $anything) {{$anything}} @endforeach
when you pass it to your controller it should be : $opt=json_encode($request->opt);
Please or to participate in this conversation.