asp两组字符串数据比较合并相同数据(3)
Nums = getSPNum(s_array(i))
for j=i+1 to ubound(s_array)
if getSPName(s_array(i)) = getSPName(s_array(j)) then
Nums = Nums + Cint(getSPNum(s_array(j)))
redim Preserve ID(q)
ID(q) = j
q = q + 1
end if
next
redim Preserve result(p)
result(p) = getSPName(s_array(i)) & "=" & Nums
p = p + 1
end if
next
for each x in result
mainhb=mainhb&x&";"
next
end function
整体函数为
<%
dim result()
dim ID()
dim p , q , Nums
p=0
q= 0
Nums = 0
redim Preserve ID(q)
ID(q) = ""
s = "sp4=33;sp2=20;sp1=34;sp3=2;sp2=3;sp4=4;"
s = left(s,len(s)-1)
response.write mainhb(s)
function mainhb(s)
s_array = split(s,";")
for i = 0 to ubound(s_array)
if not IsInID(i) then
Nums = getSPNum(s_array(i))
for j=i+1 to ubound(s_array)
if getSPName(s_array(i)) = getSPName(s_array(j)) then
Nums = Nums + Cint(getSPNum(s_array(j)))
内容版权声明:除非注明,否则皆为本站原创文章。