Say I have the following:
$str = "1AAABBCCCDDDDDDD";
How can I remove all the duplicate characters in the string? So it would look like this?
$result = "1ABCD";
All you need is count_chars():
count_chars()
$result = count_chars( $str, 3);
With the second parameter $mode set to 3, count_chars() will output:
$mode
3
a string containing all unique characters
You can see from this demo that this produces:
1ABCD
1.4m articles
1.4m replys
5 comments
57.0k users