Hello Reader's If you have a string with words occurs more than two times then here you can see how to remove them as a single.
Lets see the string below full of random words and 34 is repeating.
$mystring = '2,34,two,findnerd,logic,66,34,55,blog';
Now we will process the string in two phase.
phase 1 explode the string and phase 2 select only index value(Unique Values)
$MystringNoRepeat = implode(',',array_unique(explode(',', $mystring )));
Here first use of array_unique to get all the unique values and second implode function will concatenate them into a single string named as, $MystringNoRepeat.
0 Comment(s)