3

In my config/locale.php I have an array 'displayLanguage' which contain key=>value pairs How can I loop through this array in blade ? I have tried the following

@foreach ( {{ Config::get('app.locale.displayLanguage') }}  as $itemKey => $itemVal)
         {{ $itemKey }}
@endforeach

I am getting syntax error, unexpected '<'. tried also some other veriation to loop this var without passing it through the controller

uri wald
  • 328
  • 1
  • 5
  • 9

1 Answers1

7

If your file is in config/locale.php then you call config('locale.displayLanguage');

@foreach(config('locale.displayLanguage') as $key => $value)
    {{ $key }}
@endforeach

I am using the global helper config() in a blade file.

It also appears you have extra curly braces in your foreach loop

EddyTheDove
  • 12,979
  • 2
  • 37
  • 45