I'm using laravel blade. I try to print array of data as a column in a table. then, I put a conditional expression inside the loop to avoid printing the same value in the same column. After that my data printed twice in the first iteration.Here is the code
{{ $prevKomponen = null }}
{{ $prevKegiatan = null }}
@foreach($data as $key => $value)
<tr>
@if ($prevKomponen != $value['komponen'])
<td>{{ $value['komponen'] }}***</td>
@else
<td>-------</td>
@endif
{{ $prevKomponen = $value['komponen'] }}
<td>{{$value['kegiatan']}}</td>
<td>{{$value['subkegiatan']}}</td>
<td>{{$value['rincian']}}</td>
<td>{{$value['jumlah']}}</td>
<td>{{$value['harga']}}</td>
<td>{{$value['total_harga']}}</td>
</tr>
@endforeach
And here is the result. Data in column 1 is also printed in column 2
Any help to address this problem ?