Thi*_*agu 3 php string array-unique
下面是我的变量,
$string = 'AAA,BBB,aAA,BbB,AAA,BbB';
Run Code Online (Sandbox Code Playgroud)
我需要下面的唯一字符串结果,
$string = 'AAA,BBB,aAA,BbB';
Run Code Online (Sandbox Code Playgroud)
如何使其独特就像array_unique()函数一样,是否有任何默认的String函数来删除PHP中的重复字符串?
我不知道php是否有这样的功能,但你可以像这样处理它: live demo
$raw = 'AAA,BBB,aAA,BbB,AAA,BbB';
$string = implode(',', array_unique(explode(',', $raw)));
Run Code Online (Sandbox Code Playgroud)