remove duplicate values from entity reference fields
<p>When i import feeds into an entity reference field, it creates duplicate values that look like the code below (using devel module)</p>

<pre><code>$field_tags_people['und'][0]['target_id'] = 578
$field_tags_people['und'][1]['target_id'] = 578
$field_tags_people['und'][2]['target_id'] = 594
</code></pre>

<p>each of the target_id should have different values but turns out some are duplicates. I have tried this code </p>

<pre><code>$field_tags_people['und'] = array_unique($field_tags_people['und'])
</code></pre>

<p>but it removes all terms except the first one. This seems strange due to the target_id key. How can I make this work?</p>