When i import feeds into an entity reference field, it creates duplicate values that look like the code below (using devel module)
$field_tags_people['und'][0]['target_id'] = 578
$field_tags_people['und'][1]['target_id'] = 578
$field_tags_people['und'][2]['target_id'] = 594
each of the target_id should have different values but turns out some are duplicates. I have tried this code
$field_tags_people['und'] = array_unique($field_tags_people['und'])
but it removes all terms except the first one. This seems strange due to the target_id key. How can I make this work?
There's probably better ways to accomplish this but here's a solution.
This'll trim the duplicates out for you. but be reminded that the key structure will not be reset so you could have keys going in the order like 0, 1, 6, 7, 10
Cheers
EDIT: Online Example: http://sandbox.onlinephpfunctions.com/code/9b4323a0b07ab8cd46b34a3715ea030f83e0b100