Welcome Guest, Not a member yet? Register   Sign In
Accessing config file arrays
#1

[eluser]Unknown[/eluser]
Hi!

I'm interested, is there a method to simplify accessing an array inside a config file.

my_config.php:
Code:
$config['my_array'] = array(
   'key1' => 'value1',
   'key1' => 'value2'
);

Works:
Code:
$this->config->load('my_config');
$values = $this->config->item('my_array');
echo $values['key1'];

Doesn't work:
Code:
$this->config->load('my_config');
echo $this->config->item('my_array')['key1'];

Question is - is it possible to make it work (what changes do i need to do) ??

Sorry, for my english Smile,
Thanks !
#2

[eluser]charlieD[/eluser]
You can do this to access an item in an array directly:

Code:
$this->config->item('key1', 'my_array');




Theme © iAndrew 2016 - Forum software by © MyBB