开发者

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-&g开发者_运维知识库t;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 ;)


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

$config = $this->config->config;


    $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..


If you get multidimentional array from config files in Codeigniter then In application/config/config.php

$config['name']='array_name';

In Model or Controller file

$variable = $this->config->item('name');

var_dump($variable);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜