【发布时间】:2019-06-19 14:18:22
【问题描述】:
所以我有这个:
array(2) { [0]=> string(2) "cd" [1]=> string(6) "feegeg" }
我有这个代码:
foreach ($elem as $key => $value) {
echo preg_replace('{(.)\1+}','$1',$value);
}
哪些输出:
cdfegeg
但我需要它来输出:
cdfeg
我需要 preg_replace() 或者不使用 preg_replace() 做什么,这样我才能得到这个输出?
【问题讨论】:
-
你能找到唯一的而不是删除重复的吗?我认为这里的答案可能会有所帮助stackoverflow.com/questions/15391395/…
标签: php string duplicates