ASP函数过滤数组中重复数据方法

来源:asp之家 时间:2010-01-02 20:32:00 

因为要用到过滤一组中重复的数据,使之变成没有重复的一组数据的功能,百度了一下,居然有朋友乱写,而且比较多,都没有认真测试过,只对字符可以,但是对数字就不可以,而且通用性很差,需要修改才可以真正使用。

没办法就自己写了,经过测试完全没有问题,而且思路很方便,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" 
cxarraynull(s,",")
%> 

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

标签:函数,重复数据,数组,asp
0
投稿

猜你喜欢

  • FckEditor配置手册中文教程详细说明

    2010-02-28 12:37:00
  • SQL查询不重复记录/删除重复记录

    2008-11-18 16:08:00
  • 分支任务:从哪里来,回哪里去

    2009-09-04 18:58:00
  • OraclePL/SQL单行函数和组函数详解

    2010-07-28 13:02:00
  • 一个js自动完成功能源码

    2011-06-06 07:42:00
  • XHTML中用途相似的标签

    2008-03-24 19:33:00
  • ASP教程:制作登陆验证页面程序

    2008-10-23 15:00:00
  • asp如何做一个密码“生成器”?

    2010-07-12 18:51:00
  • phpMyAdmin下载、安装和使用入门

    2007-06-15 11:00:00
  • 用JMail、CDONTS发送邮件asp源码

    2007-09-24 15:58:00
  • msxml3.dll 错误 ‘800c0005’解决方案

    2009-10-05 18:36:00
  • 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等

    2011-12-01 07:53:11
  • Select下拉列表控件美化

    2008-11-12 12:55:00
  • 浅谈web分析

    2008-12-02 15:52:00
  • 走中国特色的网站重构道路

    2010-04-08 16:10:00
  • sql怎样显示出评论最多的文章?

    2008-08-08 12:17:00
  • SQL Server数据库对于应用程序的关系

    2010-09-08 09:42:00
  • MYSQL5 下的兼容说明(my.ini my.conf)

    2008-02-23 10:13:00
  • MYSQL数据库表设计与优化(一)

    2010-10-25 19:50:00
  • 在数据库‘master’中拒绝CREATE DATABASE权限问题的解决方法

    2011-10-24 19:46:55
  • asp之家 网络编程 m.aspxhome.com