I am trying to convert this PHP code:
<?php
foreach ($arr as $v) {
echo '<tr><td>' . $v['bookTitle'] . '</td><td>';
$ar = array();
foreach ($v['authors'] as $key => $value) {
**$ar[] = '<a href="all?authorID=' . $key . '">' . $value . '</a>';**
}
echo implode(' , ', $ar) . '</td></tr>';
}
?>
into Laravel code, but have problems
@foreach ($arr as $v)
<tr><td> {{ $v['bookTitle'] }}</td><td>
<?php $ar = array(); ?>
@foreach ($v['authors'] as $key => $value)
***$ar[] = <a href="all?authorID=' . $key . '"> . $value . </a>;*** //{{ Html::link("all?authorID= $key", "$value")}}
@endforeach
{{implode(' , ', $ar)}}</td></tr>
@endforeach
Can someone please help me with this?
@foreach ($arr as $v)
<tr><td> {{ $v['bookTitle'] }}</td><td>
@php $ar = array(); @endphp
@foreach ($v['authors'] as $key => $value)
@php $ar[]; @endphp = {{ Html::link("all?authorID= $key", "$value")}}
@endforeach
{{implode(' , ', $ar)}}</td></tr>
@endforeach
FatalErrorException Cannot use [] for reading
@php [..] @endphpand not rewrite it using blade until you re-factor to process the authors within your controller?