문제

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