How to update a field value for a node? I want to change the value of a field for a node.I used the following code:


$node = node_load($nid); // $nid is the function's parameter
$node->field['field_myfield'][$node->language][0]['value'] = 1;
node_save($node);



The problem is $node-&gt;language returns es while in print_r($node) it's und.
Why $node-&gt;language is different from what's in $node array and how can I get it?
$node = node_load($nid);
$node_wrapper = entity_metadata_wrapper('node', $node);
$node_wrapper-&gt;field_myfield-&gt;set(1);
$node_wrapper-&gt;save();


Entity metadata wrapper is a great way for set or read values of fields in the node!