Template conditional based on a list field I have a 'List (text)' field set up with five options displayed as a series of checkboxes.

I would like the last of these checkboxes to control the visibility of a button in the node template.

&lt;?php if($node-&gt;field_the_checkbox_field['und'][0]['value'] == 'key_of_checkbox'): ?&gt;
    // do stuff
&lt;?php endif; ?&gt;


The problem with the above is that it only works when this checkbox is the only one selected, otherwise it is no longer the '[0]' result.

How could I go about checking all of the potential five checkboxes for my result?

Thanks!

EDIT

I thought I'd found a horribly verbose workaround by checking every offset one by one like so:

&lt;?php if($node-&gt;field_the_checkbox_field['und'][0]['value'] == 'key_of_checkbox'
    || $node-&gt;field_the_checkbox_field['und'][1]['value'] == 'key_of_checkbox'
    || $node-&gt;field_the_checkbox_field['und'][2]['value'] == 'key_of_checkbox'): ?&gt;
        // do stuff
&lt;?php endif; ?&gt;


etc... but, now I get an 'undefined offset' error for each offset that doesn't exist, ie. not all of the boxes will ever be checked, and so there are never usually five results, meaning that when only two of these checkboxes are checked offsets 2 - 4 don't exist. PHP doesn't like that, apparently.

I'm wondering if my problem here is that I should be using five boolean checkboxes, which at least will always return a result one way or another. That seemed messy when I was planning this out, but now it's looking ever more inviting!

EDIT 2

Since I'm short on time, I decided to go with my thoughts above and base my conditionals on single points of data which can either return me a 'true' or 'false' status. My PHP (as you can probably see above) is crappy to say the least - far too crappy to work out how to get around this one. I'd be interested if anyone has any ideas regarding this though!

Thanks for reading.

EXTRA EDITS for clarity and grammar
My php isn't the best, but I think this should work...

You could try using a foreach loop, and using a condition similar to this:

&lt;?php foreach ($node-&gt;field_the_checkbox_field['und'] as $thisfield) {
    if($thisfield['value'] == 'key_of_checkbox'):
   // do stuff
} ?&gt;