How string can be removed recurring characters and only stay unique chars in Php? For example: this is the string xsxssssdddxxxs I need the result should be xsd
Asked
Active
Viewed 57 times
2 Answers
1
Maybe like this,
$str = 'aassdd';
echo implode('',array_unique(str_split($str, 1)));

zrinath
- 106
- 4
0
You can do something like this:
$str = "my string that contains multiple same charactersasldjasj";
echo implode('',array_unique(str_split($str, 1)));

Željko Krnjić
- 2,356
- 2
- 17
- 24