, , , , ,, ,,,'; $splitTags = explode(',', $inputTags); $splitTagsWithoutEmpty = []; foreach ($splitTags as $tag) { if (trim($tag) !== '') { $splitTagsWithoutEmpty[] = trim($tag); } } $splitTagsWithoutEmptyAndDuplicate = array_unique($splitTagsWithoutEmpty); ...? ....?