Laravel Blade 循环遍历配置数组变量
Laravel Blade loop through config array variable
在我的 config/locale.php 中,我有一个包含键=>值对的数组 'displayLanguage'
我如何在 blade 中遍历这个数组?
我尝试了以下
@foreach ( {{ Config::get('app.locale.displayLanguage') }} as $itemKey => $itemVal)
{{ $itemKey }}
@endforeach
我收到语法错误,意外的“<”。还尝试了一些其他的验证来循环这个 var 而不通过控制器传递它
如果您的文件在 config/locale.php
中,那么您调用 config('locale.displayLanguage')
;
@foreach(config('locale.displayLanguage') as $key => $value)
{{ $key }}
@endforeach
我在 blade 文件中使用全局助手 config()
。
您的 foreach
循环中似乎还有额外的花括号
在我的 config/locale.php 中,我有一个包含键=>值对的数组 'displayLanguage' 我如何在 blade 中遍历这个数组? 我尝试了以下
@foreach ( {{ Config::get('app.locale.displayLanguage') }} as $itemKey => $itemVal)
{{ $itemKey }}
@endforeach
我收到语法错误,意外的“<”。还尝试了一些其他的验证来循环这个 var 而不通过控制器传递它
如果您的文件在 config/locale.php
中,那么您调用 config('locale.displayLanguage')
;
@foreach(config('locale.displayLanguage') as $key => $value)
{{ $key }}
@endforeach
我在 blade 文件中使用全局助手 config()
。
您的 foreach
循环中似乎还有额外的花括号