Php 如何合并laravel刀片中的foreach循环?
我在刀片模板中使用嵌套的foreach,但所有记录都是重复的。我试过的代码如下Php 如何合并laravel刀片中的foreach循环?,php,laravel,foreach,Php,Laravel,Foreach,我在刀片模板中使用嵌套的foreach,但所有记录都是重复的。我试过的代码如下 <tbody> @foreach($ordertaker as $ot) @foreach($totalorder as $tord) <tr> <td> {{ $ot->total_visit }}/{{ $tord }} </td&
<tbody>
@foreach($ordertaker as $ot)
@foreach($totalorder as $tord)
<tr>
<td>
{{ $ot->total_visit }}/{{ $tord }}
</td>
</tr>
@endforeach
@endforeach
</tbody>
@foreach($ordertaker作为$ot)
@foreach($totalorder作为$tord)
{{$ot->total_visit}/{{$tord}
@endforeach
@endforeach
如果在db中,我有值
总访问量=[10,30]和总和=[20,40]
然后我有了输出
10/20
10/20
20/40
20/40
但要求的结果是
10/20
20/40
是否有一种方法可以使用单循环来获得两个结果示例
@foreach($ordertaker作为$ot&$totalorder作为$tord)
试试这个,希望它能起作用。如果你使用两个循环,那么如果你有两个结果,它们就会相乘,这就是为什么你会得到4个结果
<tbody>
@foreach($ordertaker as $key => $ot)
<tr>
<td>
{{ $ot->total_visit }}/{{ $totalorder[$key] }}
</td>
</tr>
@endforeach
</tbody>
@foreach($key=>$ot的订单接受者)
{{$ot->total_visit}/{{$totalorder[$key]}
@endforeach
thanx感谢您的帮助,工作人员会一直来的