Welcome Guest, Not a member yet? Register   Sign In
How to echo a value from an array using the Language class
#1

[eluser]thekrow[/eluser]
The question might sound silly but if I have a multidimensional array in a language file, how can I load the content in my view? Say in my controller I have

Code:
class Statics extends CI_Controller {



public function index($page = 'home')
{
  // load language file
  $this->lang->load($page);
  $this->load->view($page);
}
}

And then in my language file

Code:
$lang = array(
  
'description'   => array(    
    'main'  => 'Convallis habitant ultrices torquent consectetur sagittis eget metus magna elit fermentum diam tortor ad viverra nec consectetur id ac aliquam hac lobortis malesuada elit, elementum mollis tempor aliquam per nulla ipsum. Molestie non elit nec ante leo nam hendrerit aenean mauris aenean iaculis fringilla.')
    
);

How can I echo 'main'? I've tried the following to no avail. Thanks for your help.


Code:
<p>&lt;?php echo lang('description.main')?&gt;</p>

&lt;!-- I know it's wrong but tried it anyway --&gt;
<p>&lt;?php echo lang('home.description.main')?&gt;</p>

Please note that my program was tested successfully if I have something like $lang['description.main'] = 'text here...'. For me it would be better to have all my data in an mutlidimensional array.
#2

[eluser]thekrow[/eluser]
Anyone? please.
#3

[eluser]CroNiX[/eluser]
Looking at the very short Lang.php code should quickly give you your answer on whether or not this class is set up for multidimensional arrays.




Theme © iAndrew 2016 - Forum software by © MyBB