You are here

function variable_format_options in Variable 7

Same name and namespace in other branches
  1. 6 variable.variable.inc \variable_format_options()
  2. 7.2 variable.variable.inc \variable_format_options()

Format options variable. Value is an array of options.

1 string reference to 'variable_format_options'
variable_variable_type_info in ./variable.variable.inc
Implements hook_variable_type_info().

File

./variable.variable.inc, line 182
Variable module hook implementations

Code

function variable_format_options($variable, $options = array()) {
  $variable = variable_build_options($variable, $options);
  $names = array();
  if (isset($variable['value']) && $variable['value']) {
    if (is_array($variable['value'])) {
      foreach ($variable['value'] as $index => $value) {
        $names[$index] = isset($variable['options'][$value]) ? $variable['options'][$value] : t('<Invalid option>');
      }
      return implode(', ', $names);
    }
    else {
      return t('<Invalid value>');
    }
  }
  else {
    return variable_format_empty($variable);
  }
}