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

首頁 > 語言 > JavaScript > 正文

ASP 過濾數(shù)組重復數(shù)據(jù)函數(shù)(加強版)

2024-05-06 14:09:49
字體:
供稿:網(wǎng)友
函數(shù)代碼:
代碼如下:
<%'*******************************************************
'過濾數(shù)組重復函數(shù)名稱:array_no(cxstr1,cxstr2,cxstr3)
'cxstr1:任意的字符串,自動識別
'cxstr2:cxstr1中分割符號。
'cxstr3:提取結(jié)果中的某一位置字串,等于0時返回為全部,大于數(shù)組下標時返回最后.
'使用于二維數(shù)組
'*******************************************************
function array_no(cxstr1,cxstr2,cxstr3)
if len(cxstr3) > 0 then
if not IsNumeric(cxstr3) then
array_no = "對不起,參數(shù)3類型必需為數(shù)字"
Exit Function
end if
else
array_no = "對不起,參數(shù)3類型必需為數(shù)字"
Exit Function
end if
if isarray(cxstr1) then
array_no = "對不起,參數(shù)1不能為數(shù)組"
Exit Function
end if
if cxstr1 = "" or isempty(cxstr1) then
array_no = "沒有數(shù)據(jù)"
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
array_no = right(sss,len(sss)-len(cxstr2))
array_no = left(array_no,len(array_no)-len(cxstr2))
if cxstr3 <> 0 then
cx_sp = split(array_no,cxstr2)
if cxstr3 > ubound(cx_sp) then
array_no = cx_sp(ubound(cx_sp))
else
array_no = cx_sp(cxstr3)
end if
end if
end function%>


下面是測試代碼:
代碼如下:
<%s1 = "abc,aa,bb,cdef,bc,abcdef,hhgg,gggg,cde,edc"
s2 = "1,2,3,11,22,33,12,13,14,11,33,333,14"
s3 = ""
s4 = "sdf,abc,12,2,2,abc"
s5 = split(s4)
response.write "字串為字符時:"&array_no(s1,",",0)&"<br>"
response.write "字串為數(shù)字時:"&array_no(s2,",",0)&"<br>"
response.write "字串為空時:"&array_no(s3,",",0)&"<br>"
response.write "字串為混合時:"&array_no(s4,",",0)&"<br>"
response.write "字串為數(shù)組時:"&array_no(s5,",",0)&"<br>"
response.write "字串為未知變量時:"&array_no(s33,",",0)&"<br>"
response.write "提取某一位時,沒有超過下標時:"&array_no(s1,",",2)&"<br>"
response.write "提取某一位時,超過下標時:"&array_no(s1,",",200)&"<br>"%>

測試結(jié)果:
代碼如下:
字串為字符時:abc,aa,bb,cdef,bc,abcdef,hhgg,gggg,cde,edc
字串為數(shù)字時:1,2,3,11,22,33,12,13,14,333
字串為空時:沒有數(shù)據(jù)
字串為混合時:sdf,abc,12,2
字串為數(shù)組時:對不起,參數(shù)1不能為數(shù)組
字串為未知變量時:沒有數(shù)據(jù)
提取某一位時,沒有超過下標時:bb
提取某一位時,超過下標時:edc


錯新站長站增強版本: 解決了數(shù)組常見錯誤
代碼如下:
<%
'*******************************************************
'過濾數(shù)組重復函數(shù)名稱:array_no(cxstr1,cxstr2,cxstr3)
'cxstr1:任意的字符串,自動識別
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 两当县| 邵武市| 神池县| 馆陶县| 玉门市| 来凤县| 凭祥市| 兴城市| 扬州市| 桐庐县| 太谷县| 湟源县| 诸城市| 本溪| 叙永县| 凌源市| 濮阳市| 札达县| 金华市| 泸州市| 博乐市| 垦利县| 五华县| 威信县| 榆林市| 分宜县| 清流县| 宿松县| 来安县| 壶关县| 观塘区| 六枝特区| 宁国市| 简阳市| 广德县| 石泉县| 岗巴县| 廊坊市| 阳泉市| 大庆市| 杭锦旗|