The problem is your double @foreach which will result in count($info) x count($books) results. This is why you see 28 outputs with 4 of those being a match ( "Book" )
Good to know, what should i do to fix this problem? Any idea Thanks
this might be a viable solution for you.
// create an array of book names
$bookNames = $books->pluck('name');
// loop over the files you have
@foreach($info as $file)
// is filename in your book array
@if(in_array($file, $books) )
<p>Book</p>
@else
<p>No Book</p>
@endif
@endforeach
Thanks for your answer but its not working just gettin No book 7 times
$bookNames[] = $books->pluck('name');
// loop over the files you have
@foreach($info as $file)
// is filename in your book array
@if(in_array($file, $booksNames) )
<p>Book</p>
@else
<p>No Book</p>
@endif
@endforeach
And i tried but its not working
<?php
$bookNames[] = $archivos->pluck('name');
//dd(count($bookNames[0]));
$i = 0;
?>
// loop over the files you have
@foreach($info as $file)
// is filename in your book array
<?php $i++; ?>
@if(($i< count($bookNames[0]))?($file['filename'] == $bookNames[0][$i]):true )
<p>Book</p>
@else
<p>No Book</p>
@endif
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community