Actually, I want an array like this in .env file. I do not have any idea to create an array variable in .env file.
VARIABLE_NAME = [
[0] => 'Value 1',
[1] => 'Value 2',
[2] => 'Value 3',
................
];
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 file
VARIABLE_NAME="Value 1,Value 2,Value 3"
#config/app.php
return [
'VARIABLE_NAME' => explode(',', env('VARIABLE_NAME'))
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With