Below is the variable I have,
$string = 'AAA,BBB,aAA,BbB,AAA,BbB';
I need the unique string result below,
$string = 'AAA,BBB,aAA,BbB';
How to make it unique just like array_unique()
function , is there any default String function to remove duplicate string in PHP?
I don't know if php have such function, but you can process it like this: live demo
$raw = 'AAA,BBB,aAA,BbB,AAA,BbB';
$string = implode(',', array_unique(explode(',', $raw)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With