PHP method for stripping duplicate chars from a multibyte string?

请求翻译

Arrrgh. Does anyone know how to create a function that's the multibyte character equivalent of the PHP count_chars($string, 3) command?

Such that it will return a list of ONLY ONE INSTANCE of each unique character. If that was English and we had

"aaabggxxyxzxxgggghq xcccxxxzxxyx"

It would return "abgh qxyz" (Note the space IS counted).

(The order isn't important in this case, can be anything).

If Japanese kanji (not sure browsers will all support this):

汉汉汉字汉字私私字私字汉字私汉字汉字私

And it will return just the 3 kanji used:

汉字私

It needs to work on any UTF-8 encoded string.

3个回答