Method 1:
Copy codeThe Code is as follows:
$ Text = 'array aabbccdd ';
$ Text_filter = '';
$ Filter = array ();
$ Len = mb_strlen ($ text, 'utf-8 ');
For ($ I = 0; $ I <$ len; $ I ++ ){
$ Char = mb_substr ($ text, $ I, 1, 'utf-8 ');
If (! Isset ($ filter [$ char]) {
$ Text_filter. = $ char;
$ Filter [$ char] = $ char;
}
}
Echo $ text_filter;
Method 2:
Copy codeThe Code is as follows:
$ String = 'array aabbccdd ';
Function str_split_utf8 ($ str ){
$ Split = 1;
$ Array = array ();
For ($ I = 0; $ I <strlen ($ str );){
$ Value = ord ($ str [$ I]);
If ($ value & gt; 127 ){
If ($ value >=192 & $ value <= 223)
$ Split = 2;
Elseif ($ value >=224 & $ value <= 239)
$ Split = 3;
Elseif ($ value >=240 & $ value <= 247)
$ Split = 4;
} Else {
$ Split = 1;
}
$ Key = NULL;
For ($ j = 0; $ j <$ split; $ j ++, $ I ++ ){
$ Key. = $ str [$ I];
}
Array_push ($ array, $ key );
}
Return $ array;
}
Print_r (array_unique (str_split_utf8 ($ string )));
Method 3:
The array_unique () function is used to separate each word into an array.