Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何在经典ASP中相互使用两个Split()函数?_Arrays_Loops_For Loop_Vbscript_Asp Classic - Fatal编程技术网

Arrays 如何在经典ASP中相互使用两个Split()函数?

Arrays 如何在经典ASP中相互使用两个Split()函数?,arrays,loops,for-loop,vbscript,asp-classic,Arrays,Loops,For Loop,Vbscript,Asp Classic,我的页面中有两个变量(getYear和getBranch) getYear-1,4,11 getBranch-4,5,7 GetYearSingle = Split(getYear, ",") 我在Split()函数之后得到单个数组值,如下所示: For Each iLoop In GetYearSingle response.write "<br>Year= " & iLoop Next getYear = "1,4,11" getBranch = "4,5,7"

我的页面中有两个变量(
getYear
getBranch

getYear-1,4,11
getBranch-4,5,7

GetYearSingle = Split(getYear, ",")
我在
Split()
函数之后得到单个数组值,如下所示:

For Each iLoop In GetYearSingle
  response.write "<br>Year= " & iLoop
Next
getYear = "1,4,11"
getBranch = "4,5,7"
GetYearSingle中每个iLoop的

response.write“
Year=“&iLoop 下一个
我得到这样的结果

year=1 year=4 year=11 year=1 Branch=4 year=4 Branch=5 year=11 Branch=7 年份=1 年份=4 年份=11 但我需要这样的结果

year=1 year=4 year=11 year=1 Branch=4 year=4 Branch=5 year=11 Branch=7 年份=1 分支=4 年份=4 分支=5 年份=11 分支=7
我想这是孤注一掷

getYear-1,4,11
getBranch-4,5,7
实际上应该是这样的:

For Each iLoop In GetYearSingle
  response.write "<br>Year= " & iLoop
Next
getYear = "1,4,11"
getBranch = "4,5,7"
如果是这种情况,您希望在逗号处拆分两个字符串,并使用
For
循环(而不是
For Each
循环)迭代两个数组的元素

arrYear   = Split(getYear, ",")
arrBranch = Split(getBranch, ",")

For i = 0 To UBound(arrYear)
  response.write "<br>Year= " & arrYear(i)
  response.write "<br>Branch= " & arrBranch(i)
Next
arrYear=Split(getYear,“,”)
arrBranch=Split(getBranch,“,”)
对于i=0至UBound(一年)
response.write“
Year=“&arrYear(i) response.write“
Branch=“&arrBranch(i) 下一个
我假设你是孤注一掷

getYear-1,4,11
getBranch-4,5,7
实际上应该是这样的:

For Each iLoop In GetYearSingle
  response.write "<br>Year= " & iLoop
Next
getYear = "1,4,11"
getBranch = "4,5,7"
如果是这种情况,您希望在逗号处拆分两个字符串,并使用
For
循环(而不是
For Each
循环)迭代两个数组的元素

arrYear   = Split(getYear, ",")
arrBranch = Split(getBranch, ",")

For i = 0 To UBound(arrYear)
  response.write "<br>Year= " & arrYear(i)
  response.write "<br>Branch= " & arrBranch(i)
Next
arrYear=Split(getYear,“,”)
arrBranch=Split(getBranch,“,”)
对于i=0至UBound(一年)
response.write“
Year=“&arrYear(i) response.write“
Branch=“&arrBranch(i) 下一个
您需要通过(同步)索引对两个数组进行循环:

输出:

cscript 44118915.vbs
Microsoft (R) Windows Script Host, Version 5.812
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

1 4
4 5
11 7

您需要通过(同步化)索引循环两个数组:

输出:

cscript 44118915.vbs
Microsoft (R) Windows Script Host, Version 5.812
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

1 4
4 5
11 7