I'm creating a website in CodeIgniter, I wanted to know if this way of using a multidimensional array in the language file would create any problems, like this:

$lang['profile']['name'] = 'The text to be shown';

This way I can use one file for multiple things and also I can to loop thru buttons this way:

$lang['profile_btns']['1'] = 'Text btn 1';
$lang['profile_btns']['2'] = 'Text btn 2';
//Etc...

I read the values like this:

foreach ($this->lang->line('profile_btns') as $key => $value){
    echo $value;
}

This is working fine, but I'm not sure if using this method would/could create any issue due to the non-standard CI use (this is not written in the CI manual).

有帮助吗?

解决方案

Actually your codes right except spelling. Use profile_btns in foreach instead of profile_btn

foreach ($this->lang->line('profile_btns') as $key => $value){
    echo $value;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top