$str = str_replace(PHP_EOL, "\n",$str);
$arr = array_unique(explode("\n",$str)); foreach ($arr as &$item){
$item = trim($item);
}