Ternary operator not evaluating checkbox values I am using Drupal 7. I have created a form using the Form API, in which I defined several checkboxes. The form sends its contents in an email and this works fine at the moment as long as I simply output the values of the fields, with the checkboxes outputting the value if checked (e.g. Elderly) and 0 if not. In making up the body of the email I want the zeros to be omitted and only the values of the checked boxes to appear. I have tried to achieve this by using a shorthand ternary operator to include some html if the box is checked and not if not. I can't get this to work. Here's how I've defined the checkboxes in the form itself:

$hometypes = array(
            'Elderly' =&gt; t('Elderly'),
            'Disabled' =&gt; t('Disabled'),
            'Council tenant' =&gt; t('Council tenant'),
            'Home owner' =&gt; t('Home owner')
            );

        $form['personaldetails']['survey']=array(
            '#type'=&gt;'checkboxes',
            '#title'=&gt;t('Please indicate your situation by ticking the appropriate boxes'),
            '#description'=&gt;t('You can tick a box by clicking on it once'),
            '#options'=&gt;$hometypes
            );


Here's where I set up the variable $elderly:

$elderly = $form_state['values']['survey']['Elderly'];


And here's the section of the submit function that is not working:

  .($elderly == 'Elderly' ? '&lt;td&gt;Elderly&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;' : '&lt;td&gt;').


This returns the 'True' value regardless of whether the box is checked or not. If I change it to be:

  .($elderly &lt;&gt; 0 ? '&lt;td&gt;Elderly&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;' : '&lt;td&gt;').


it returns the 'False' value regardless of whether the box is checked or not.

This may be a bit of a newbie question, but that's because I'm a bit of a newbie! Any help gratefully received.
Solved it!

I redefined the keys for my checkboxes as values rather than strings. Like so:

$hometypes = array(
        1 =&gt; t('Elderly'),
        2 =&gt; t('Disabled'),
        3 =&gt; t('Council tenant'),
        4 =&gt; t('Home owner')
        );


remembering to change this:

$elderly = $form_state['values']['survey'][1];


which means that this:

($elderly == 1 ? '&lt;td&gt;Elderly&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;' : '&lt;td&gt;')


works perfectly.