Laravel Blade 在 foreach 中使用 if 条件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24281678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Blade using if condition inside foreach
提问by Friend
here is my code ..
这是我的代码..
@foreach (Session::get('show_my_data') as $key1 => $value1)
<div class="sb_li">
<input id="sb_system_input_{{ $value1->Myid }}" class="fr_cap" type="text" disabled name="fr_cap[{{ $value1->Myid }}]" value="{{ $value1->FRCapacity }}" maxlength="127"/>
</div>
@foreach ($m002_siteinfo as $key => $value)
@if({{!$value1->name}})
<div class="sb_li">
<input id="sb_system_input_{{ $value->Myid }}" class="fr_cap" type="text" disabled name="fr_cap[{{ $value->Myid }}]" value="" maxlength="127"/>
</div>
@endif
@endforeach
@endforeach
I am trying to display values of Second foreach
which is not there in first foreach
using if condition
in the middle, but iam getting syntax error
in Laravel ,Blade templete.. any ways to fix this??
我正在尝试显示 中间Second foreach
没有first foreach
使用的值if condition
,但是我正在syntax error
进入 Laravel,Blade 模板……有什么方法可以解决这个问题?
回答by Needpoule
You don't need the {{ }}
syntax inside the @if
您不需要{{ }}
@if 中的语法
You can just write
你可以写
@if(!$value1->name)