Codeigniter: How to access multidimensional arrays in config file with Controller? Codeigniter: How to access multidimensional arrays in config file with Controller? codeigniter codeigniter

Codeigniter: How to access multidimensional arrays in config file with Controller?


Please write without brackets;

$this->values = $CI->config->item('example_config', 'frontend1');


You can read all of them like this:

       $data = $this->config->item('frontend1');       print_r($data); 

or you can read one by one like this:

$my_title = $this->config->item('my_title','frontend1');echo $my_title;


Config file:

$config['permissions'] = [           [              'name' => 'Xem',              'key' => 'view',              'val' => 0           ],           [              'name' => 'Thêm',              'key' => 'add',              'val' => 0           ]        ];

Template file:

echo '<pre>';print_r($this->config->item('permissions'));echo '</pre>';die;

And result:

Array(  [0] => Array    (        [name] => View        [key] => view        [val] => 0    )   [1] => Array    (        [name] => Add        [key] => add        [val] => 0    ))