- implode: documentation ( source)
- explode: documentation ( source)
- trim: documentation ( source)
- array_unique: documentation ( source)
<?php
function utils_removeDuplicates($str, $delimiter = ',') {
if($str != '') {
$strArray = explode($delimiter, $str);
foreach ($strArray as $value) {
$value = trim($value);
}
$str = implode($delimiter,array_unique($strArray));
}
return $str;
}
$data = "88, 99, 99,99, 100,1 0 0, 88 ";
echo utils_removeDuplicates($data);