Php 仅当用户选择的所有注册类型的总价大于0时,才显示一些HTML
在我看来,我有这样一个理由:Php 仅当用户选择的所有注册类型的总价大于0时,才显示一些HTML,php,laravel,Php,Laravel,在我看来,我有这样一个理由: @foreach($selectedRtypes as $k => $selectedRtype) @foreach(range(1,$selectedRtype['quantity']) as $val) .... @endforeach @endforeach 如果用户选择的所有注册类型的总价大于0,我想在blade视图中显示一些html 你知道怎样才能做到吗 {dd$selectedRtypes}}显示: array:2 [▼
@foreach($selectedRtypes as $k => $selectedRtype)
@foreach(range(1,$selectedRtype['quantity']) as $val)
....
@endforeach
@endforeach
如果用户选择的所有注册类型的总价大于0,我想在blade视图中显示一些html
你知道怎样才能做到吗
{dd$selectedRtypes}}显示:
array:2 [▼
"general" => array:6 [▼
"quantity" => "2"
"price" => 5
"subtotal" => 10
"total" => 10
"questions" => Collection {#243 ▼
#items: array:1 [▶]
}
"id" => 1
]
"plus" => array:6 [▼
"quantity" => "1"
"price" => 10
"subtotal" => 10
"total" => 20
"questions" => Collection {#247 ▼
#items: []
}
"id" => 2
]
我不知道下面这样是否正确,因为我只检查了一种注册类型的价格:
@foreach($selectedRtypes as $k => $selectedRtype)
@foreach(range(1,$selectedRtype['quantity']) as $val)
....
@if($selectedRtype['price']>0)
<p>show this html</p>
@endif
@endforeach
@endforeach
将价格保存在另一个变量中,如 $price=0; $price=$price+$selectedType['price'] 然后如果$price>0,做点什么