I'm trying to echo keywords from a MySQL database, separated by colon, and remove (don't show) duplicates.
This is what I got.
Keywords in DB
Love:Sorrow:Death
Happiness:Love:Excitement
Excitement:Speed:Love
PHP
<?php
$myKeyArr = array();
while($rowKeyword = mysqli_fetch_array($sqlKeyword)){
$myKeywords = explode(':', $rowKeyword['keywords']);
$myKeyArr[] = $myKeywords;
}
foreach ($myKeyArr as $value) {
$kw = array_unique($value);
echo $kw['0'] . "<br>";
}
?>
I just want to echo the following
Love
Sorrow
Death
Happiness
Excitement
Speed
This is what's shown
Love
Sorrow
Death
Happiness
Love
Excitement
Excitement
Speed
Love