Reputation: 27
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
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
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