laravel 我如何知道 Blade 模板中数组的大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24816257/
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
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:53:42 来源:igfitidea点击:
How can i know the size of an array in Blade template?
提问by Andy.Diaz
I need something like this:
我需要这样的东西:
@if ($array.length > 0)
{{-- expr --}}
@endif
is this possible?
这可能吗?
Solution!
解决方案!
@if (count($array) > 0)
{{-- expr --}}
@endif
采纳答案by dragoon
You can use the php count function to count the length of an array.
您可以使用 php count 函数来计算数组的长度。
回答by Andy.Diaz
Ouch...
哎哟...
@if (count($array) > 0)
{{-- expr --}}
@endif