How to print the value of an array instead of the key? I have the code below in a form builder for Drupal 7:

$form['color'] = array(
  '#type' =&gt; 'select',
  '#required' =&gt; TRUE,
  '#title' =&gt; t('Color:'),
  '#options' =&gt; array(
    0 =&gt; t('Blue'),
    1 =&gt; t('Yellow'),
  )
);


I need to print the selected value in hook_mail but I only get the key when I write:

function color_mail($key, &amp;$message, $params) {
  global $user;
  $message['subject'] = 'Selected color is: ' . $params['color']
}


While what would make sense here would be to print the value, not the key. I tried $params['color']['#options']; too but it didn't work.

Any tip on how to make this work? I'm sure it's something simple I don't yet know about.
The form submission process will only actually keep hold of the array key (which is the value for the select element), so it won't be available to you in $params.

The usual method to handle this sort of thing is to provide a function to return the options:

function MYMODULE_colour_options() {
  return array(
    0 =&gt; t('Blue'),
    1 =&gt; t('Yellow'),
  );
}


Then in your form function you would use:

$form['color'] = array(
  '#type' =&gt; 'select',
  '#required' =&gt; TRUE,
  '#title' =&gt; t('Color:'),
  '#options' =&gt; MYMODULE_colour_options()
);


And in the message hook:

$colour_options = MYMODULE_colour_options();

$colour_string = 'Unknown';
if (isset($colour_options[$params['color']])) {
  $colour_string = $colour_options[$params['color']];
}

$message['subject'] = 'Selected color is: ' . $colour_string;