I have a duplicate dynamic number of slash / characters in my variable, for example:
$string = 'test////test2';
$string2 = '///test//test3';
$string3 = 'xsss/////ss/';
i want to remove duplicate / slash character next to each other. so it only leaves one /slash character, like this:
$string = 'test/test2';
$string2 = '/test/test3';
$string3 = 'xsss/ss/';
I already tried the suggestion from this answer
$string = preg_replace('/,+/', '/', $string);
$string = rtrim($string, '/');
but it's not working at all, it's still outputting the original string