Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
说我有以下内容:
$str = "1AAABBCCCDDDDDDD";
如何删除字符串中的所有重复字符?所以它看起来像这样?
$result = "1ABCD";
您只需要count_chars():
count_chars()
$result = count_chars( $str, 3);
将第二个参数$mode设置为3,count_chars()将输出:
$mode
3
包含所有唯一字符的字符串
您可以从这个演示中看到,这会产生:
1ABCD