jeudi 19 février 2015

If else statement in codeigniter

i want to create if-else statement in codeigniter with my logic



If $language === "english"


it will no change



$q["question_title"] = $q["question_title"]


else


it will change



$q["question_title"] = $q["question_title_**id**"]


the point is, i want to add "_id" in every php if $languege = no "english"


how to do that if php code inside of "[]" like $q["question_title"]


OR from query.php



// translation language
$site_lang = $this->session->userdata('site_lang');
if ( $site_lang === 'english') {
$question['questions'][$i]['question_title'] = $q->quiz_text;
} else {
$question['questions'][$i]['question_title'] = $q->quiz_text_id;
}


so if i use code in /views and it read cookies in "english" it will get database "quiz_text" but if else it will get "quiz_text_id" from database but it not work in my query code.


Aucun commentaire:

Enregistrer un commentaire