软件教程

asp中join函数实现字符串连接

来源: 本站    类别: 软件教程    日期: 2016/2/2

 

文章利用了join函数来实例字符连接以及数组array连接,相对于&这种连接速度要好很多,下面我们看实例。

(list[,delimiter])

参数 描述 
list Required. A one-dimensional array that contains the substrings to be joined
必选项。包含要联接的子字符串一维数组。 
delimiter Optional. The character(s) used to separate the substrings in the returned string. Default is the space character
可选项。在返回字符串中用于分隔子字符串的字符。如果省略,将使用空字符 ("")。 如果 delimiter 是零长度字符串,则在同一列表中列出全部项,没有分界符。

实例 1

 代码如下
dim a(5),b
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
b=Filter(a,"n")
document.write(join(b))
输出:Sunday Monday Wednesday

实例,测试效率

 代码如下
<% 
Dim a(10000),i,t 
t=Timer 
For i=0 to 10000 
a(i)=CStr(i) 
Next 
Response.Write Join(a,vbCrLf) 
Response.Write timer-t 
Erase a 
%> 

速度可以和php一拼(虽然还是没有他快),
另一种用法是

 代码如下
s=Join(Array("1","2","3",.....,"9999"))

速度依然比"1" & "2" & "3" & .....& "9999"要快很多


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com