ASP将两个数组合并为一个数组函数 array_merge()

王朝学院·作者佚名  2009-05-05
窄屏简体版  字體: 小  |  中  |  大  |  超大  

<%

' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.

'

' This work is licensed under the Creative Commons Attribution License. To view

' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or

' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California

' 94305, USA.

' Merge two arrays into one.

function array_merge(byVal firstArray, byVal secondArray)

dim totalSize

dim i

dim combinedArray

' Ensure that we're dealing with arrays.

if not isArray(firstArray) then

firstArray = Array(firstArray)

end if

if not isArray(secondArray) then

secondArray = Array(secondArray)

end if

' Set up the new array.

totalSize = uBound(firstArray) + uBound(secondArray) + 1

combinedArray = firstArray

redim preserve combinedArray(totalSize)

for i = 0 to uBound(secondArray)

combinedArray(uBound(firstArray) + 1 + i) = secondArray(i)

next

array_merge = combinedArray

end function

%>

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航