I know the title probably didn't make sense, so I'll clarify what I mean. What I'm looking for is a way to cut down repetition of a character (for example, aaaa) down to just 1 of that character (a), so aaaa -> a Thank you!
The trim function only works with the beginning and end of the string. I'm looking for something that trims in the middle.
Try a preg_replace: $string = preg_replace('/aaaa/','a',$string); PHP: Let us know if your $string could contain bbbb, or cccc, or other situations that aren't necessarily pre-identifiable.
jestep, I'm only looking for repeated occurrences of one character, but is there a way to cut down repeated occurrences (starting with 2 or more) down to just one? So the scenario is, I don't know if there will be 2, 3, 4, or even more As, but if there are, I need to trim that down to just 1.