在我的
config/locale.php
中,我有一个数组displayLanguage
,其中包含“键=>值”对。
如何在 Blade 中循环遍历这个数组?
我尝试过以下方法:
@foreach ( {{ Config::get('app.locale.displayLanguage') }} as $itemKey => $itemVal)
{{ $itemKey }}
@endforeach
我收到语法错误,意外'<'. Tried also some other variation to loop this var without passing it through the controller.
如果您的文件位于
config/locale.php
那么您可以致电 config('locale.displayLanguage')
;
@foreach(config('locale.displayLanguage') as $key => $value)
{{ $key }}
@endforeach
我在刀片文件中使用全局助手
config()
。
您的
foreach
循环中似乎还有额外的大括号