从Codeigniter中的配置文件中获取完整数组

Ahm*_*mad 8 config codeigniter

我做了很多搜索我的问题,但我没有得到任何东西..

在codeigniter中,当我使用配置文件时,我这样做:

my_config.php:

$config['my_title'] = ' My Title Here ' ;
$config['color']    = ' red ' ;
Run Code Online (Sandbox Code Playgroud)

我可以像这样检索它:

$this->load->config('my_config', TRUE );
$data['my_title'] = $this->config->item('my_title', 'my_config');
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何获得完整的数组来处理它?

我希望$ config作为一个数组来做这样的事情:

 foreach($config as $key=>$val){
          $data[$key] = $val ;
        }
Run Code Online (Sandbox Code Playgroud)

所以我不必在配置文件中写下我的所有变量,如下所示:

$data['my_title'] = $this->config->item('my_title', 'my_config');
$data['color'] = $this->config->item('color', 'my_config');
Run Code Online (Sandbox Code Playgroud)

等等 ..

抱歉我的英语不好!

提前致谢 ;)

Jos*_*ber 11

虽然这是未记录的,并且可能在将来的版本中中断,但您可以通过以下方式访问主配置数组:

$config = $this->config->config;
Run Code Online (Sandbox Code Playgroud)