How can I loop through entity reference values? My content type "Export" has an entity reference to the type "country" (i.e. you assign countries to the export). I wish to do something like the following

$countries = $node-&gt;field_exporter_countries['und'][0]['value'];

foreach ($countries as &amp;$value) {
   print $value;
}


Edit

I also tried this. But i get the wrong titles back. 

$nodes = entity_load('node', array_keys($countries));
foreach ($nodes as $n) {
  print $n-&gt;title;
  print "&lt;br /&gt; ";
}
According to the entityreference_field_schema() function, the column name for an entity reference field is target_id (not value). That said, to extract the node ids you should probably use something like this:

$nids = array();
foreach ($node-&gt;field_exporter_countries[$node-&gt;language] as $index =&gt; $item) {
  $nids[] = $item['target_id'];
}

$nodes = entity_load('node', $nids);

// etc...