Welcome Guest, Not a member yet? Register   Sign In
Add to global $config array

Hey guys!

How would I add to the global config array?
I have an email config file and would like to add some default values in it so I can pick them up using $this->email->etc etc

Can it be done?


You can create another config file and access that via the config library, or you can just stick the data in your config.php file:
$config['email_settings'] = array(
        'protocol' => 'sendmail',
        'mailpath' => '/usr/sbin/sendmail',
        'charset' => 'iso-8859-1',
        'wordwrap' => TRUE

Then you can grab the array like this:
$email_config = $this->config->item('email_settings');

Thanks man, that'll do it!

I wish CI had a way to call array items using config->item().... something like

It does if you read.

CodeIgniter Users Guide - Config Class

I've read through that and I see no examples that require more than a single tier of nested array. It also appears to require the tier be named after the file.

You can always extend the class and make it do whatever you want.

Theme © iAndrew 2016 - Forum software by © MyBB