亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

ASP

asp數(shù)組重復刪除函數(shù)

時間:2024-05-15 11:42:48 ASP 我要投稿
  • 相關推薦

asp數(shù)組重復刪除函數(shù)

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

  復制代碼 代碼如下:

  <%

  function cxarraynull(cxstr1,cxstr2)

  if isarray(cxstr1) then

  cxarraynull = "對不起,參數(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ù)中的兩個參數(shù):

  cxstr1:要檢測的數(shù)組變量,可以為空,或其它未知的錯誤數(shù)據(jù),當為空或則為錯誤數(shù)據(jù)返回"nodate"。

  cxstr2:數(shù)組的分割符號,可以為空,或為chr(13)等,自動替換輸出。

  2、測試代碼:

  <%

  s="1,2,3,4,2,3,5,3"

  s=cxarraynull(s,",")

  response.write s

  %>

  輸出:1,2,3,4,5

  增強版本,解決了數(shù)組中最后一位的,逗號問題。

  復制代碼 代碼如下:

  <%

  function cxarraynull(cxstr1,cxstr2)

  if isarray(cxstr1) then

  cxarraynull = "對不起,參數(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

  %>

  測試代碼:

  復制代碼 代碼如下:

  s="1,2,3,4,55,55,55,333,333,2,3,5,3,88,,,,,,,66,,66,,,,,,,,,,,,,,,,,,,,,,,,"

  s=cxarraynull(s,",")

  response.write s

【asp數(shù)組重復刪除函數(shù)】相關文章:

ASP的特點與功能04-20

excel函數(shù)07-30

excel函數(shù)[優(yōu)選]07-31

EXCEL函數(shù)公式大全08-01

Excel函數(shù)公式大全07-27

(經(jīng)典)excel函數(shù)15篇08-02

EXCEL函數(shù)公式大全[經(jīng)典]08-05

常用的Excel函數(shù)公式11-23

如何刪除Vista下EISA硬盤的隱藏分區(qū)07-16

用dos命令新建和刪除賬戶-net user07-17