asp如何去除数组重复的数据
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
:asp如何去除数组重复的数据![]() <%
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")%> <iframe id="aswift_1" name="aswift_1" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="854" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-6370479498472259&output=html&h=280&slotname=6129565636&adk=3842234981&adf=3641306162&pi=t.ma~as.6129565636&w=854&fwrn=4&fwrnh=100&lmt=1692342823&rafmt=1&format=854x280&url=https%3A%2F%2Fwww.lmlphp.com%2Fuser%2F57910%2Farticle%2Fitem%2F2585586%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&dt=1692342823550&bpp=2&bdt=2758&idt=305&shv=r20230816&mjsv=m202308100101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D37cf471cea7fa576-22ecca31aade00ce%3AT%3D1681548366%3ART%3D1689402950%3AS%3DALNI_Mb7-tBHbOXBuqxHP_M2z0H4N9m_Tw&gpic=UID%3D00000bf4b851950b%3AT%3D1681548366%3ART%3D1689402950%3AS%3DALNI_MZxETlQwAjL1W9vrpEsvyZrSxUBKA&prev_fmts=300x600&correlator=1385262228240&frm=20&pv=1&ga_vid=519501620.1681548365&ga_sid=1692342824&ga_hid=760591905&ga_fc=1&u_tz=480&u_his=1&u_h=720&u_w=1280&u_ah=680&u_aw=1280&u_cd=24&u_sd=1.5&dmc=8&adx=362&ady=731&biw=1263&bih=578&scr_x=0&scr_y=114&eid=44759837%2C44759876%2C44759927%2C31076469%2C31077148%2C44799580%2C44796897&oid=2&pvsid=894709231477277&tmod=893709583&uas=3&nvt=1&ref=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DsUCC-xlhJY00t7YRI1mpid_Y_PwaY7rHVYlGO3XspNM_yyahGJ2dELpTUltvFs8DpGOlprZV5gnTIv1SvC5eeh6oAY_ZYCcxKqaWkRrOfIW%26wd%3D%26eqid%3D84bcff460002d2950000000664df1a12&fc=896&brdim=0%2C0%2C0%2C0%2C1280%2C0%2C1280%2C680%2C1280%2C578&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=lN0vWk8Llp&p=https%3A//www.lmlphp.com&dtd=314" data-google-container-id="a!2" data-load-complete="true" data-google-query-id="CKyy86bU5YADFYtgDwIdZsEAFA" style="left: 0px; position: absolute; top: 0px; border-width: 0px; border-style: initial; width: 854px; height: 0px;"></iframe> 结果是:abc,dge,gcg,die,dir 如果是两个数组进行对比,去掉相同的数组元素: <%
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)
%>结果是: 3.数组A中有为空的元素(如a=array("ww","ss","","dd","","ee")),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,",") 该文章在 2023/8/18 15:15:20 编辑过 |
关键字查询
相关文章
正在查询... |