Get Values from field collection on Drupal 7

Let’s supose you have an user with a field collection named “field_certification” and you have a field that references to a field called field_class_type.

$myuser = user_load($user->uid);
//Get certifications ids without entity interpretation
$certifications_array = $myuser->field_certification[LANGUAGE_NONE];
 

In $certifications_array you will obtain ids taht do not match the terms, so you need to conver them to get the correct value:

//Convert obtained ids to terms
$certifications = array();
foreach($certifications_array as $certification){
$entity = entity_load('field_collection_item', array($certification['value']));

if(!isset($entity[$certification['value']]->field_class_type[LANGUAGE_NONE])) continue;

$term_id = $entity[$certification['value']]->field_class_type[LANGUAGE_NONE][0]['tid'];

if(!empty($term_id))
$certifications[] = $term_id;
}