如何在Laravel框架中使用while或loop语句

问题描述 投票:1回答:3

我想用foreach创建一个表,同时又要创建一个表...我想自动创建一组新的表

@if(count($collection) > 0)
<div class="arrg arrg_in" style="cursor: pointer;" width="100%">
    <table class="arrg_tbarrg" border="0" cellpadding="2" cellspacing="2" width="100%">
        <tbody>
            @foreach($collection as $collectios)
            @foreach($collectios->tansactions as $transaction)
            @if($transaction) 
<tr style="background-color:red">
<td> hello</td> </tr> @endif 
@endforeach 
@foreach($collectios->ptansactions as $transactio)
@if($transactio)
<tr style="background-color:red">
<td> hello people</td>
</tr>
@endif
@endforeach
</tbody>
</table>

@endforeach
@endif

我希望出现一组全新的完整表格...

我将在哪里使用while语句

laravel
3个回答
1
投票

尝试使用Laravel的isEmpty()检查集合是否为空。


0
投票

尝试此


0
投票

我想这里不需要使用while loop,但是如果您仍然想使用while loop,请尝试下面的代码。

© www.soinside.com 2019 - 2024. All rights reserved.