I have a string of numbers, separated by comma. How do I strip duplicate values in a string? Do i need to convert it to array to do that and then back to the string?
1339,41,1909,1339,41,1909
Do i need to convert it to array to do that and then back to the string?
That is what I would do.
$string = '1339,41,1909,1339,41,1909'; $array = explode(',', $string); $array = array_unique($array); $string = implode(',', $array); echo $string;
Great, thanks!