Jam Dvia
Jam Dvia

Reputation: 27

CodeIgniter get multiple items in config file

I would like to get multiple items in config file in CodeIgniter.

I want to loop this array then echo it . how to do that ?

Config file:

$config['test']=array('AAA','BBB');

How can i echo those two items in controller ?

Best regards,

Upvotes: 0

Views: 1063

Answers (2)

Suleman Ahmad
Suleman Ahmad

Reputation: 2113

supposed you have loaded config file already

$item_arr = array();
$items = $this->config->config['test'];   // get the array items from config
foreach($items AS $item){
    $item_arr[] = "'".$item."'";
}
$all_items = implode(',',$item_arr);
echo $all_items;

Upvotes: 0

Nishant Jani
Nishant Jani

Reputation: 1993

try doing like this :

$this->load->config('your_config_file_name');
$test_arr = $this->config->item('test');
foreach($test_arr as $t){
echo $t;
} 

OR

print_r($test_arr);

Upvotes: 1

Related Questions