Why do we use "target_id" as the name of the index in php instead of "entity_id"?
target_id is generally used in entity references.  So if you have an entity reference to another entity the target_id is the id of that entity.  This depends if it is a node or an entity though.  But I will mention that generally you want to avoid $entity-&gt;field_fieldname['und'][0]['entity_id'] but instead using the entity_metadata_wrapper to target values instead:

$node = node_load($nid);
$node_wrapper = entity_metadata_wrapper('node', $node);

$mytitle = $node_wrapper-&gt;title // Title
$myfield = $node_wrapper-&gt;field_my_field-&gt;value(); // Value of the field, cleaner

You can also use the set method
$node_wrapper-&gt;field_my_field-&gt;set("My value"); // If single value

$node_wrapper-&gt;save(); // Save my entity