PHP - If a field has a certain text value then print something The following PHP in a node tpl file:

check_plain($node-&gt;field_room[$node-&gt;language][0]['value'])


Will print this in the page:
Value1

What I want however is if the field has a value of 'Value1' then I want to print something else on the page. Ive tried the following but I think I have a syntax error: 

if ( check_plain($node-&gt;field_room[$node-&gt;language][0]['value']) == "Value1" ) {
                        echo "&lt;p&gt;Print something else &lt;/p&gt;";
                    }
There's no syntax error in the second code sample, if you're getting a syntax error it's not coming from those lines.

The best way to get values from an entity is with field_get_items():

$items = field_get_items('node', $node, 'field_room');
if (count($items) &amp;&amp; check_plain($items[0]['value']) == 'Value1') {
  // Do something
}


But unless you have some sort of multi-lingual issue the code you've got should do exactly the same thing as that, so the problem might be elsewhere.