entitymetadawrapper with field collection multi value How can I save multiple values in a multi-value field collection using EntityMetadataWrapper ?

Here's some of my code

$field_collection = entity_create('field_collection_item', array('field_name' =&gt; 'MY_FIELD_COLLECTION'));
$field_collection-&gt;setHostEntity('commerce_line_item', $line_item);
$wrapper = entity_metadata_wrapper('field_collection_item', $field_collection);

for($delta=0; $delta&lt;$max_delta; $delta++) {
  //MISSING something like $wrapper-&gt;setDelta($delta);
  $wrapper-&gt;field_example-&gt;set($new_value);  
  $wrapper-&gt;other_field_example-&gt;set($new_value); 
  $wrapper-&gt;save(); 

}

$field_collection-&gt;save();


I'm fighting with the field delta : I can't use $wrapper-&gt;field_example[$delta]-&gt;set($new_value) because the wrapper itself is the multi-value field, not its children fields.

So I need to find a way to perform something like

$wrapper[$delta]-&gt;field_example-&gt;set($new_value); 


But this returns "Fatal error: Cannot use object of type EntityDrupalWrapper as array".

Summary : where can I set the delta of the wrapper in the loop ?
I've found this example in one of the bug reports on d.o, hopefully it will clear things up a bit:

// Load the entity and wrap it.
$entity = entity_load_single('my_entity', $entity_id);
$wrapper = entity_metadata_wrapper('my_entity', $entity);
// Create new field collection items.
$collections = array();
// This is a contrived example so assume $things contains some data that might be set on the collections.
foreach ($things as $thing) {
  $fc = entity_create('field_collection_item', array('field_name' =&gt; 'field_example_collections'));
  $fc-&gt;setHostEntity('my_entity', $entity, $entity-&gt;language, FALSE);
  // Skip saving the host entity since the order in which we are creating the items is not the order we want them saved.
  $fc-&gt;save(TRUE);
  $collections[] = $fc;
}
// Set the field collection items via the wrapper.
$wrapper-&gt;field_example_collections-&gt;set($collections);
// Save the entity.
$wrapper-&gt;save();


Just as @Clive commented, you need to first load the host entity that this field collection field is attached to (I'm assuming it's a commerce_line_item?), then loop through your data and create field collection entities. Then after you've done assigning values, collect them all in an array and set the array as the new value for the host entity's field collection field.