I have a column with rows of tags. In each row, I have each tag separated with a comma and space.
for example: BMW M5, Leather Seats, 24 Inch Wheels, etc.
What I need to do is loop through the array, explode it, and then print the values to the page. So far I have been able to do it; however, it prints the duplicates.
Here is the code I have so far:
$cleanTags = ($row_getTags['tags']);
$cleanerTags = str_replace(', ', "-", $cleanerTags);
$tagstr = ($cleanerTags);
$tags = explode('-', $tagstr);
foreach ($tags as $tag)
{
echo "<li><a href=\"results.php?search=" . str_replace(" ", '%20', $tag) . "\" title=\"Find more stuff tagged: " . $tag . "\" class=\"tagLink\">" . $tag . "</a></li>";
}
How can I go about removing duplicates from the array? I've tried array_unique() with no luck.
array_unique?array_unique(). This question is Unclear, No-Repro, and Needs Debugging Details.