I have a question about for loop. I am saving json data just in one column. For example:
1 / John / ["jsondata1","jsondata2","jsondata3"]
2 / Elizabeth / ["jsondata3","jsondata4"]
I need to show this values in a table. 3rd column max data size is allways 4. there is no jsondata5
I was created this loop in my blade view.
<table>
@foreach($values as $value)
<tr>
<td>{{$value->id}}</td>
<td>{{$value->name}}</td>
@for ($i = 0; $i < 4; $i++)
<td>{{$value->jsondata[$i]}}</td>
@endfor
</tr>
@endforeach
</table>
In this case i am getting some errors.
Error is "Undefined offset: 2"
When i tried for ($i = 0; $i < 2; $i++)
it just show the last 2 data.
But if i tried $i < 4
there is an error.
What is the right way to do this for loop? I tried so much ways.