Reputation: 3514
I have the following function.
The problem is that the $lang variable will vary depending on the $this->setts['site_lang'];
. The actual problem is the following:
$condition_details['description_$lang']
(which isn't working). How do I get this to display
$condition_details['description_us']
or
$condition_details['description_fr']
depending on the $lang setting?
And here is the full function:
function shipped_drop_down($box_name = 'item_shipped_via', $selected = null, $form_refresh = null)
{
(string) $display_output = null;
$lang = $this->setts['site_lang'];
$sql_select_conditions = $this->query("SELECT id, description_".$lang." FROM " . DB_PREFIX . "advanced_shipping_carriers ORDER BY theorder,description_".$lang." ASC");
$display_output = '<select name="' . $box_name . '" ' . (($form_refresh) ? 'onChange = "submit_form(' . $form_refresh . ', \'\')"' : '') . ' style="font-size:10px; width: 120px;"> ';
while ($condition_details = $this->fetch_array($sql_select_conditions))
{
$display_output .= '<option value="' . $condition_details['id'] . '" ' . (($condition_details['id'] == $selected) ? 'selected' : '') . '>' . $condition_details['description_$lang'] . '</option> ';
}
$display_output .= '</select> ';
return $display_output;
}
Upvotes: 1
Views: 79
Reputation: 3345
Use double quotes like so:
$condition_details["description_$lang"]
Upvotes: 0
Reputation: 76880
You could do
$condition_details['description_'.$lang]
or use "
$condition_details["description_$lang"]
Upvotes: 5
Reputation: 720
You could store your lang settings in arrays like this :
$lang['fr']['condition_details']
so you could use $lang[$selected_lang]['condition_details']
Upvotes: 2
Reputation: 324640
Use "double quotes" instead of 'single quotes'. That way the $lang
will be parsed and replaced with the relevant value.
Upvotes: 1