I'm trying to access array from config file and use it in my dropdown list.
<select id="iconSelector" name="iconChoose" class="form-control" style="width: 100%">
@foreach(array(Config::get('azima')) as $icon)
<option value="{{$icon}}">{{$icon}}</option>
@endforeach
</select>
I have 'azima.php' file in config folder, which returns array and looks like this
<?php
return [
"ti-arrow-up",
"ti-arrow-right",
"ti-arrow-left",
"ti-angle-double-up"
];
The problem is it is working fine in other projects. What could be the problem?
You get null
maybe because the file hasn't been autoloaded. Clearing the cache and autoload dumping should do the trick
composer dump-autoload
php artisan config:clear
php artisan config:cache
You don't have to cast it to an array:
<select id="iconSelector" name="iconChoose" class="form-control" style="width: 100%">
@foreach(Config::get('azima') as $icon)
<option value="{{$icon}}">{{$icon}}</option>
@endforeach
</select>
在终端上运行此命令
php artisan config:clear
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.