<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Here's some code I use for dealing with collections. Perhaps it will help you to solve you problem.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span><span style="color: rgb(0, 0, 255);"><span style="font-size: 13px;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp; $collection = field_get_items($entity_type, $entity, 'field_consultant_cost_breakout');<br>&nbsp; $count = count($collection);<br><br>&nbsp; $total = 0;<br>&nbsp; for ($i = 0; $i &lt; $count; ++$i) {<br>&nbsp;&nbsp;&nbsp; // Entity_load will return an array with the entity number as the key.<br>&nbsp;&nbsp;&nbsp; $item = array_pop(entity_load('field_collection_item',
 array($entity-&gt;field_consultant_cost_breakout[LANGUAGE_NONE][$i]['value'])));<br>&nbsp;&nbsp;&nbsp; $total += $item-&gt;field_total_cost[LANGUAGE_NONE][0]['value'];<br>&nbsp; }</span></span><br></span><br></span></div><div>&nbsp;</div><div><font color="#ff007f" face="bookman old style, new york, times, serif" size="4"><i><b>Nancy</b></i></font> <br></div><div><font face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</font></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font face="Arial" size="2"> <b><span style="font-weight:bold;">From:</span></b> Wipe_Out &lt;wipe_out@users.sourceforge.net&gt;<br> <b><span
 style="font-weight: bold;">To:</span></b> support@drupal.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 28, 2013 6:05 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> [support] Accessing values in the $node variable..<br> </font> </div> <div class="y_msg_container"><br>
<div id="yiv788369144"><div dir="ltr">Probably a simple syntax question but as a non-programmer I am battling with it..<div><br></div><div style="">I have created an "Invoice" content type that uses an entity reference to a "Patient" content type and within that there is a field collection for addresses.. I am trying to get the address in the first item in the field collection..</div>
<div style=""><br></div><div style="">My guess is that I have to use something like "entity_load" which I will have to work out when I get there but at the moment I can't work out the syntax for accessing the field collection ID so I can try and load the data for the field collection..<br></div></div></div></div> </div> </div> </blockquote></div>   </div></body></html>