In addition to the repeated words in the string, the index string is generated. the string parameter is a string that has been segmented. In addition to the repeated words in the string, the index string is generated. the string parameter is a string that has been segmented and processed ------------------------------------ functiongetindextext ($ okstr,/removes the repeated words in the string to generate the index string, the string parameter is a string that has been segmented.
//--------------------------------------------------
Function getindextext ($ okstr, $ ilen =-1)
{
If ($ okstr = "") return "";
$ Ws = explode ("", $ okstr );
$ Okstr = "";
$ Wks = "";
Foreach ($ ws as $ w)
{
$ W = trim ($ w );
// Exclude characters smaller 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 v) $ okstr. = $ w ."";}
Else
{
Foreach ($ wks as $ w =>v v ){
If (strlen ($ okstr) + strlen ($ w) + 1) <$ ilen) $ okstr. = $ w ."";
Else break;
}
}
}
Return trim ($ okstr );
}?>
Else // ---------------------------------------------------- function getindextext ($ okstr ,...