egturnkey Posted October 5, 2009 Share Posted October 5, 2009 Hello Friends, I've an function which has an array in arabic now i want when lang goes english is shows me it but in english as follow if lang=en show function f1 and if lang=ar show function f2 below the code but indeed show error ( not in function but in closing if and if not ) can you please fix it ! if($lang == "en") /////////////// function ////////// function career_level($c, $id) { $levels = array("xxxxxxxx", "xxxxxxxxx"); if($id >= '0') { $level = $levels[$id]; return $level; } else { $select = "<select class='qc_textbox'name=\"careerlevel\">\n\t"; while(list($k,$v) = each($levels)) { if($c >= '0') { if($c == $k) { $select .= "<option value=\"$k\" selected>$v</option>\n\t"; } else { $select .= "<option value=\"$k\">$v</option>\n\t"; } } else { $select .= "<option value=\"$k\">$v</option>\n\t"; } } $select .= "</select>\n\n"; return $select; } } ////////////////////////////////////////// else if($lang == "ar") ////////////////// same function ////////// function career_level($c, $id) { $levels = array("xxxxxxxx", "xxxxxxxxx"); if($id >= '0') { $level = $levels[$id]; return $level; } else { $select = "<select class='qc_textbox'name=\"careerlevel\">\n\t"; while(list($k,$v) = each($levels)) { if($c >= '0') { if($c == $k) { $select .= "<option value=\"$k\" selected>$v</option>\n\t"; } else { $select .= "<option value=\"$k\">$v</option>\n\t"; } } else { $select .= "<option value=\"$k\">$v</option>\n\t"; } } $select .= "</select>\n\n"; return $select; } } Link to comment https://forums.phpfreaks.com/topic/176510-if-en-then-f1-and-if-ar-then-f2/ Share on other sites More sharing options...
RussellReal Posted October 5, 2009 Share Posted October 5, 2009 SIMPLE! <?php $func = (($lang == "en")? "f1"($lang == "ar")? "f2":"en")); // now you use $func as if it was your function $func("whatever"); ?> Link to comment https://forums.phpfreaks.com/topic/176510-if-en-then-f1-and-if-ar-then-f2/#findComment-930447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.