Did you ever have two arrays that you needed to merge together? If you were programming in PHP, you used the array_merge() function. If you were programming in ASP, you had to write a whole bunch of code because there is no array_merge() function... until now.
ASP
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
No comments:
Post a Comment