Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get full array from config files in Codeigniter

I did a lot of search for my problem but I did not get anything ..

in codeigniter when I use config files I do that :

my_config.php :

$config['my_title'] = ' My Title Here ' ;
$config['color']    = ' red ' ;

I can retrieve it like this :

$this->load->config('my_config', TRUE );
$data['my_title'] = $this->config->item('my_title', 'my_config');

My question is : How can I get the full array to deal with it ?

I want the $config as an array to do something like this :

 foreach($config as $key=>$val){
          $data[$key] = $val ;
        }

so I do not have to write all my variables that in config file like this :

$data['my_title'] = $this->config->item('my_title', 'my_config');
$data['color'] = $this->config->item('color', 'my_config');

and so on ..

sorry for my broken English !

thanks in advance ;)

like image 992
Ahmad Avatar asked Sep 09 '11 05:09

Ahmad


2 Answers

While this is undocumented, and might break in future releases, you can access the main config array by:

$config = $this->config->config;
like image 120
Joseph Silber Avatar answered Oct 06 '22 06:10

Joseph Silber


    $config=$this->load->config('my_config', TRUE );
    $config = $this->config;
    $my_config=$config->config['my_config'];

    echo"<pre>";print_r($my_config);

It may help you..

like image 37
Vivek Aasaithambi Avatar answered Oct 06 '22 05:10

Vivek Aasaithambi