I have a entity reference field that holds relations to multiple nodes. I have to remove one item programmatically based on nid. Normally to remove item I've just set it to null like this:
$wrapper->field_foobar = NULL;
But entity reference is a list, so I have to know delta for element to do something like this:
$wrapper->field_foobar[$delta] = NULL;
So I have content_id and target_id what should I do to find delta? I know it's possible to do it with simple SQL query, but I gues there should be some way to do that with entity metadata .
I'm on Drupal 7 of course.