Laravel 5.1 create array variable in .env file for global use Laravel 5.1 create array variable in .env file for global use laravel laravel

Laravel 5.1 create array variable in .env file for global use


You can't store an array in .env file as the ENV format doesn't support that.

A workaround could be serializing the array to a string of some known format, e.g. comma separated values, and then split it whenever you needed.

This should do the trick:

#.env fileVARIABLE_NAME="Value 1,Value 2,Value 3"#config/app.phpreturn [  'VARIABLE_NAME' => explode(',', env('VARIABLE_NAME'))];