How to check if a field is empty

Jan
2014
09
How do you check that a field is empty, when you have the $node object? The function $my_field_items = field_get_items('node', $node, 'field_my_field'); returns FALSE if there is no data. isset() would actually fail because you are assigning FALSE to the variable so it's actually been set to something. The correct syntax would be:
<?php
$field
= field_get_items('node', $node, 'field_my_field');
if(
$field){
    
//Do something with the field
}else{
    
//There are no results
}
?>
Cats: 
this is an arrow pointing back to the top of the page