Issue
I want to display the following numbers in Loop 1 to 6 like this: 1 - 2
2 - 3
3 - 4
5 - 6
Solution
$range = range(1, 6);
foreach ($range as $key => $value) {
if ($key != 0) {
echo $range[$key - 1].' - '.$range[$key].PHP_EOL;
}
}
@php($range = range(1, 6))
@foreach ($range as $key => $value)
@if (!$loop->first())
<p>{{ $range[$key - 1] }} - {{ $range[$key] }}</p>
@endif
@endforeach
Answered By - IGP
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.