Search code examples
codeigniterconfig

How to call only one item from array with $this->config->item CODEIGNITER?


I have a default config file in my config directory (default.php). I've loaded it already with autoload file:

$autoload['config'] = array('default');

there is my default.php:

<?php

//$config['secretUserHashKey'] = 'g81h6JH18kASPkgAW16jS132sa186h1';
//$config['secretPhotoNameHashKey'] = 'ghOH3Hs841s98sssp1AHDWPfMHAjd';

// Pages

$config['pagesUrl'] = array(
    'home' => 'homepage',
    'login' => 'loginsite'
);

and how I should use it on my view?

<li><a href="<?=base_url($this->config->item('home'));?>">Home</a> <span class="divider">/</span></li>

with this example I can get value if mine string is'nt array:

$config['home'] = 'homepage';

so what should I do to grab item from my array?


Solution

  • Try this:

    <?php echo $this->config->item('home', 'pagesUrl');?>