最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp 數(shù)組 重復(fù)刪除函數(shù)(腳本之家增強(qiáng)版)

 更新時(shí)間:2010年05月31日 22:49:29   作者:  
這篇文章是asp下刪除重復(fù)數(shù)組的函數(shù),已經(jīng)經(jīng)過測(cè)試。

因?yàn)橐獙憘€(gè)東西用到,所以百度了一下,居然有朋友亂寫,而且比較多,都沒有認(rèn)真測(cè)試過,只對(duì)字符可以,但是對(duì)數(shù)字就不可以,而且通用性很差,需要修改才可以真正使用。沒辦法就自己寫了,經(jīng)過測(cè)試完全沒有問題,而且思路很方便,代碼很短,如下:

復(fù)制代碼 代碼如下:

<%
function cxarraynull(cxstr1,cxstr2)
if isarray(cxstr1) then
cxarraynull = "對(duì)不起,參數(shù)1不能為數(shù)組"
Exit Function
end if
if cxstr1 = "" or isempty(cxstr1) then
cxarraynull = "nodate"
Exit Function
end if
ss = split(cxstr1,cxstr2)
cxs = cxstr2&ss(0)&cxstr2
sss = cxs
for m = 0 to ubound(ss)
cc = cxstr2&ss(m)&cxstr2
if instr(sss,cc)=0 then
sss = sss&ss(m)&cxstr2
end if
next
cxarraynull = right(sss,len(sss) - len(cxstr2))
cxarraynull = left(cxarraynull,len(cxarraynull) - len(cxstr2))
end Function
%>

使用方法和函數(shù)表示:
1、cxarraynull(cxstr1,cxstr2)函數(shù)中的兩個(gè)參數(shù):
cxstr1:要檢測(cè)的數(shù)組變量,可以為空,或其它未知的錯(cuò)誤數(shù)據(jù),當(dāng)為空或則為錯(cuò)誤數(shù)據(jù)返回"nodate"。
cxstr2:數(shù)組的分割符號(hào),可以為空,或?yàn)閏hr(13)等,自動(dòng)替換輸出。
2、測(cè)試代碼:
<%
s="1,2,3,4,2,3,5,3"
s=cxarraynull(s,",")
response.write s
%>
輸出:1,2,3,4,5


腳本之家增強(qiáng)版本,解決了數(shù)組中最后一位的,逗號(hào)問題。
復(fù)制代碼 代碼如下:

<%
function cxarraynull(cxstr1,cxstr2)
if isarray(cxstr1) then
cxarraynull = "對(duì)不起,參數(shù)1不能為數(shù)組"
Exit Function
end if
if cxstr1 = "" or isempty(cxstr1) then
cxarraynull = "nodate"
Exit Function
end if
do while instr(cxstr1,",,")>0
cxstr1=replace(cxstr1,",,",",")
loop
if right(cxstr1,1)="," then
cxstr1=left(cxstr1,len(cxstr1)-1)
end if
ss = split(cxstr1,cxstr2)
cxs = cxstr2&ss(0)&cxstr2
sss = cxs
for m = 0 to ubound(ss)
cc = cxstr2&ss(m)&cxstr2
if instr(sss,cc)=0 then
sss = sss&ss(m)&cxstr2
end if
next
cxarraynull = right(sss,len(sss) - len(cxstr2))
cxarraynull = left(cxarraynull,len(cxarraynull) - len(cxstr2))
end function
%>

測(cè)試代碼:
復(fù)制代碼 代碼如下:

s="1,2,3,4,55,55,55,333,333,2,3,5,3,88,,,,,,,66,,66,,,,,,,,,,,,,,,,,,,,,,,,"
s=cxarraynull(s,",")
response.write s

相關(guān)文章

最新評(píng)論

包头市| 深州市| 福州市| 怀宁县| 资中县| 收藏| 信阳市| 甘肃省| 澎湖县| 连城县| 莱西市| 朝阳县| 图们市| 扬中市| 云霄县| 鞍山市| 涿鹿县| 崇信县| 富源县| 小金县| 昌乐县| 巴马| 江川县| 梅河口市| 石家庄市| 新丰县| 漯河市| 怀仁县| 玉屏| 乌鲁木齐市| 太原市| 兰州市| 南京市| 青河县| 汉川市| 读书| 仁化县| 庆阳市| 阜新市| 嘉禾县| 定西市|