Is there a better (faster) solution to remove duplicates from a comma separated string?
public function d($dep) { if (strpos($dep,\',\') !== false) {
Try just this:
$uniqueDep = implode(',', array_unique(explode(',', $dep)));