【发布时间】:2016-04-19 11:44:56
【问题描述】:
我有这个字符串:$entitlemnet = '43857403,erot,43857403,erot,rejh'
我想从这个字符串中删除所有重复的值。我该怎么做?
参见下面的代码。
$roql_Ent_result = RNCPHP\ROQL::query($EntQuery)->next();
while ($Ent_result = $roql_Ent_result->next())
{
$Entitlement = $Ent_result['Entitlement'];
$findme = $Entitlement.",";
$pos = stripos($EntitlementString, $findme);
if ($pos === false)
{
$EntitlementString = $EntitlementString.$Entitlement.", ";
}
}
if ($EntitlementString != "")
{
$EntitlementString = substr($EntitlementString,0,(strlen($EntitlementString)-2)).";";
}
【问题讨论】:
-
你的意思是这个字符串
43857403,erot,43857403,erot,rejh会导致43857403,erot,rejh吗?
标签: php string duplicates substring