delete a specific element within field collection programmatically This is driving me crazy it just sounds simple, but I cannot find the answer.

I have a field collection in a content type called field_collection_mine how you now while creating the node you can add elements to the field collection.

I have tried this:

$wrapper = entity_metadata_wrapper($entity_type, $entity);
$wrapper-&gt;field_collection_mine = array();
entity_save('field_collection_item',$wrapper);


The code above delete all the elements within the field collection, but that is now what I want!! I just want to delete for example the last element. E.g:


Field Collection mine
Element1
Element2
Element3


How can I for example delete just the element 3? The above code deletes all the elements, so field_collection_mine is left empty.
You need to grab the id of the field collection and wrap itself in an entity wrapper. Use the save method in the wrapper to do this instead of the entity_save function. E.g.

 $wrapper = entity_metadata_wrapper('field_collection_item', $entity);
 $wrapper-&gt;field_specific_field_collection_item-&gt;set("");


or:

$wrapper-&gt;field_specific_field_collection_item = array();
$wrapper-&gt;save();