Setting values in a config file is a great way to store data in one place, that can be accessed by lots of other pages... and a great way to change things quickly when a site goes live.
However, sometimes you want to store several things that are similar, so an array would be a good idea... This is how it's used in CodeIgniter...
The following is in the config/config.php file:
$config['format_time'] = array( 0 => 'd/m/Y' // dd/mm/yyyy , 1 => 'd/m/y' // dd/mm/yy , 2 => 'd/m/Y H:i' // dd/mm/yyyy hh:ss , 3 => 'd/m/y H:i' // dd/mm/yy hh:ss , 4 => "jS M 'y" // 1st Jan '14 , 5 => 'U' // Epoch , 6 => 'd M Y' // JS Date Picker Format , 7 => 'd M Y H:i' // JS Time Picker Format , 8 => 'jS M Y' // 1st Jan 2014 );
This is how you use in in your view:
<?php echo date($this->config->item(0,'format_time'), strtotime($itemFromDatabase)); ?>
Where the $itemFromDatabase looks like:2014-03-29 19:00:00
Main Category
Secondary Categories