国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp 數組 重復刪除函數(腳本之家增強版)

2024-05-04 11:09:38
字體:
來源:轉載
供稿:網友
這篇文章是asp下刪除重復數組的函數,已經經過測試。

因為要寫個東西用到,所以百度了一下,居然有朋友亂寫,而且比較多,都沒有認真測試過,只對字符可以,但是對數字就不可以,而且通用性很差,需要修改才可以真正使用。沒辦法就自己寫了,經過測試完全沒有問題,而且思路很方便,代碼很短,如下:

復制代碼 代碼如下:


<%
function cxarraynull(cxstr1,cxstr2)
if isarray(cxstr1) then
cxarraynull = "對不起,參數1不能為數組"
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
%>


使用方法和函數表示:
1、cxarraynull(cxstr1,cxstr2)函數中的兩個參數:
cxstr1:要檢測的數組變量,可以為空,或其它未知的錯誤數據,當為空或則為錯誤數據返回"nodate"。
cxstr2:數組的分割符號,可以為空,或為chr(13)等,自動替換輸出。
2、測試代碼:
<%
s="1,2,3,4,2,3,5,3"
s=cxarraynull(s,",")
response.write s
%>
輸出:1,2,3,4,5


腳本之家增強版本,解決了數組中最后一位的,逗號問題。

復制代碼 代碼如下:


<%
function cxarraynull(cxstr1,cxstr2)
if isarray(cxstr1) then
cxarraynull = "對不起,參數1不能為數組"
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
%>


測試代碼:

復制代碼 代碼如下:


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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 孝昌县| 屏山县| 出国| 德惠市| 道真| 井冈山市| 扎赉特旗| 三台县| 涞源县| 尉氏县| 盐亭县| 远安县| 永城市| 焦作市| 彭山县| 龙陵县| 邢台市| 南川市| 宁津县| 大石桥市| 论坛| 凌海市| 女性| 平和县| 三原县| 宁武县| 徐汇区| 云梦县| 黎川县| 莎车县| 丰镇市| 红桥区| 宜兰县| 三穗县| 邵阳市| 瑞昌市| 孟州市| 沂南县| 天门市| 筠连县| 包头市|