• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array in .env file

I was hoping from the docs here: Treating Environment Variables as Arrays that I could access something in the .env file that used dot syntax as an array but it doesn't seem to work.[url=https://codeigniter4.github.io/userguide/general/configuration.html#treating-environment-variables-as-arrays][/url]
Here is an example, after copying the env file to .env and uncommenting the database.default section:

PHP Code:
$database getenv('database');

$database just contains boolean false.

Is it possible to access everything prefixed with e.g. 'database' as an array?

It will not work because it does not have a namespace or class.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

thanks but actually I think my fault was using the getenv command.

The following works:

PHP Code:
$database config('Database');

and shows that database.default is an array

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.