My code still displays the duplicate values, even after trying both functions in_array
and array_unique
. I get values from database. Some rows have multiple values.
I want to break down those by commas and than remove duplicates.
Please Help, Thanks In Advance.
<?php while ($row = mysql_fetch_array($sql)) {
$mark=explode(',', $row['sku']);
foreach($mark as $out) {
if(!in_array($out, $array)){
$array[] = $out;
}
}
}
$unique_array = array_unique($array, SORT_REGULAR);
natsort($unique_array);
print_r($unique_array);
?>