去除数组中重复的项

80酷酷网    80kuku.com

  数组|重复

<%

'======================================
'作者:阿里西西
'时间:2005.12.20
'作用:去除数组中重复的项
'======================================
Function MoveR(Rstr)
 Dim i,SpStr
 SpStr = Split(Rstr,",")
 For i = 0 To Ubound(Spstr)
  If I = 0 then
   MoveR = MoveR & SpStr(i) & ","
  Else
   If instr(MoveR,SpStr(i))=0 and i=Ubound(Spstr) Then
    MoveR = MoveR & SpStr(i)
   Elseif instr(MoveR,SpStr(i))=0 Then
    MoveR = MoveR & SpStr(i) & ","
   End If
  End If
 Next
End Function
str1 = "abc,abc,dge,gcg,dge,dgi,die,dir,fgk,dir,gis,sgier,ssir"
response.write MoveR(str1)
%>

如果需要得到重复值的匹配率,只要在End Funciton前一句加上以下代码:

MoveR = FormatPercent(InNum/Ubound(split(MoveR,",")))

就可以得出重复值的匹配率了!

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: