在我的PHP Blade文件中,我正在构建一个foreach来打印记录|行。
我想打印这两个:
@if(isset($products->{'Décoration Chocolat et fruits'})) {{ $products->{'Décoration Chocolat et fruits'}.' | ' }} @endif
@if(isset($products->{'Décoration petites fleurs'})) {{ $products->{'Décoration petites fleurs'}.' | ' }} @endif @if(isset($products->Décoration)) {{ $products->Décoration.' | ' }} @endif
仅当
的值时 @if(isset($products->Type)) {{ $products->Type.' | ' }} @endif
等于某个“值”
此后我的foreach:
@foreach($content['order'] as $products)
<tr>
<td>
@if(isset($products->Type)) {{ $products->Type.' | ' }} @endif
@if(isset($products->Nom)) {{ $products->Nom.' | ' }} @endif
@if(isset($products->{'# Personnes'})) {{ $products->{'# Personnes'}.' | ' }} @endif
@if(isset($products->Inscription)) {{ $products->Inscription.' | ' }} @endif
@if(isset($products->{'Décoration Chocolat et fruits'})) {{ $products->{'Décoration Chocolat et fruits'}.' | ' }} @endif
@if(isset($products->{'Décoration petites fleurs'})) {{ $products->{'Décoration petites fleurs'}.' | ' }} @endif @if(isset($products->Décoration)) {{ $products->Décoration.' | ' }} @endif
@if(isset($products->Poids)) {{ $products->Poids.' | ' }} @endif
@if(isset($products->{'Assortiment 1'})) {{ $products->{'Assortiment 1'}.' | ' }} @endif
@if(isset($products->{'Assortiment 2'})) {{ $products->{'Assortiment 2'}.' | ' }} @endif
@if(isset($products->{'Assortiment 3'})) {{ $products->{'Assortiment 3'}.' | ' }} @endif
@if(isset($products->{'Assortiment 4'})) {{ $products->{'Assortiment 4'}.' | ' }} @endif
@if(isset($products->{'Couleur Ruban'})) {{ $products->{'Couleur Ruban'}.' | ' }} @endif
Prix : CHF @if(isset($products->Total)) {{ number_format($products->Total, 2) }} @endif
</td>
</tr>
@endforeach
我陷入困境,不胜感激您的专业知识。谢谢,马克
答案 0 :(得分:0)
来自@Ghost的解决方案
感谢@Ghost,您的简短有效的回答对我来说很有效:
解决方案:
!empty($ products-> Type)&& $ products-> Type ==='您需要满足的任何值'