Mam dość proste pytanie mianowicie mam taki kod
$directory = "../storage/app/backup_films/"; $filecount = 0; if ($files){ } foreach(new \DirectoryIterator($directory) as $file) if(!$file->isDot()) @foreach ($file as $file ) @if(!$file->isDot()) <tr> <th scope="row"></th> <td> {{$file}} </td> <td> <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete_">Usuń</button> </td> </tr> @endif @endforeach $count_files = $filecount;
for ($i = 0; $i <= $count_files; $i++) { }
Chciałbym się dowiedzieć gdzie dodać pętle for która będzie generować id? próbowałem już dodać w miejscu id ale robi 12345 a chciałbym żeby robiło id w każdym osobno.
Okey, gdyby ktoś był ciekawy jak to zrobić .
<?php $id = 0; ?> foreach(new \DirectoryIterator($directory) as $file) if(!$file->isDot()) <?php id++ ?> @foreach ($file as $file ) @if(!$file->isDot()) <tr> <th scope="row">{{$id}}</th> <td> {{$file}} </td> <td> <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete_">Usuń</button> </td> </tr> @endif @endforeach