asp下去除數(shù)組中重復(fù)項(xiàng)的方法
<%
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
response.write MoveR("abc,abc,dge,gcg,dge,gcg,die,dir,die")%>
結(jié)果是:abc,dge,gcg,die,dir
如果是兩個(gè)數(shù)組進(jìn)行對(duì)比,去掉相同的數(shù)組元素:
<%
Function mover(farray,sarray)
a = Split(farray, ",")
Set dic = CreateObject("Scripting.Dictionary")
For k=0 To UBound(a)
If a(k)<> "" Then dic.Add "_" & a(k), a(k)
Next
a = Split(sarray, ",")
For k=0 To UBound(a)
If a(k)<> "" Then
If dic.Exists("_" & a(k)) Then
dic.Remove "_" & a(k)
End If
End If
Next
items = dic.Items()
Set dic = Nothing
moveR=Join(items, ",")
End Function
n1 = "a,b,1,11,12,13,14,15,16,17,19,20,22"
n2 = "a,1,12,14,18,19,20"
response.write mover(n1,n2)
%>
結(jié)果是:
3.數(shù)組A中有為空的元素(如a=array("ww","ss","","dd","","ee")),
想把這些空元素從數(shù)組A中去掉.并把去掉空元素有的數(shù)組賦給數(shù)組B.
str=""
for i = lbound(A) to ubound(A)
if A(i)<>"" then
if i<>lbound(A) then str = str + "," end if
str = str & A(i)
end if
next
b = split(str,",")
相關(guān)文章
ASP生成數(shù)字相加求和的BMP圖片驗(yàn)證碼
以前我自己寫了個(gè)是文字的,但還是這個(gè)好,都是圖片的2008-08-08asp獲取客戶端某一個(gè)圖片的x,y坐標(biāo)的代碼
asp獲取客戶端某一個(gè)圖片的x,y坐標(biāo)的代碼...2007-11-11asp中使用mysql數(shù)據(jù)庫的注意實(shí)現(xiàn)
2008-01-01asp中使用MSXML2.ServerXMLHTTP實(shí)現(xiàn)異步請(qǐng)求例子
這篇文章主要介紹了asp中使用MSXML2.ServerXMLHTTP實(shí)現(xiàn)異步請(qǐng)求例子,本文還給出了MSXML2.ServerXMLHTTP異步請(qǐng)求代碼編寫最常犯的錯(cuò)誤,需要的朋友可以參考下2014-08-08查看ASP詳細(xì)錯(cuò)誤提示信息的圖文設(shè)置方法
有時(shí)候很多朋友訪問自己的asp或php等程序頁面時(shí)出現(xiàn)一些錯(cuò)誤,就是頁面無法顯示也沒有詳細(xì)的錯(cuò)誤信息,就算iis中開啟了顯示詳細(xì)的錯(cuò)誤也不能看到,那么就需要客戶端如下的設(shè)置了。2011-01-01