To remove a repeating word from a string, generate an index string
//--------------------------------------------------
function Getindextext ($okstr, $ilen =-1)
{
if ($okstr = = "") return "";
$ws = Explode ("", $okstr);
$okstr = "";
$wks = "";
foreach ($ws as $w)
{
$w = Trim ($w);
Exclude characters that are less than 2
if (strlen ($w) <2) continue;
Exclude numbers or dates
if (!ereg ("[^0-9:-]", $w)) continue;
if (strlen ($w) ==2&&ord ($w [0]) >0x80) continue;
if (Isset ($wks [$w])) $wks [$w]++;
else $wks [$w] = 1;
}
if (Is_array ($wks))
{
Arsort ($wks);
if ($ilen ==-1)
{foreach ($wks as $w = = $v) $okstr. = $w. " "; }
Else
{
foreach ($wks as $w = = $v) {
if ((strlen ($OKSTR) +strlen ($w) +1) < $ilen) $okstr. = $w. " ";
else break;
}
}
}
Return trim ($OKSTR);
}
http://www.bkjia.com/PHPjc/444979.html www.bkjia.com true http://www.bkjia.com/PHPjc/444979.html techarticle to remove duplicate words from a string, generate an index string//--------------------------------------------------function Getindextext ($okstr, $ilen =-1) {if ($okstr = =) return; $ws = Explod ...