I have a simple project where Im using laravel with blade. I recive an array called 'tablero' and I have to see all it values. I have this code:
But I received this error: Undefined constant "i" (View: /var/www/html/resources/views/tablero2.blade.php) How do i define i?
CodePudding user response:
add this before foreach
@php
$i = 0;
@endphp
CodePudding user response:
In addition to conditional statements, Blade provides simple directives for working with PHP's loop structures. Again, each of these directives functions identically to their PHP counterparts:
Solution one:
@for ($i = 0; $i < count($tablero); $i )
<p> {{ $tablero[$i] }} </p>
@endfor
Solution two:
@foreach ($tablero as $tab)
<p> {{ $tab }} </p>
@endforeach