shortest code to find the field value of any node in drupal

Viewed 262

I have been using this code in Drupal 7 to get value of a node's field:

$node = node_load($nid);
$rate = $node->field_rate[und][0][value];

How to get $rate value without using this long array syntax?

After research i get

$field = field_get_items('node', $node, 'field_rate')
$rate = $field[0]['value'];

But it is still long if i need to get n number of fields.

1 Answers
Related