字符串到数组与经典 ASP
String to Array with Classic ASP
我在 Classic ASP 中有以下代码:
Dim objHttp, strQuery
strQuery = "https://geoip.maxmind.com/f?333l=2112212&i=" & ipaddress
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.open "GET", strQuery, false
objHttp.send
Response.Write objHttp.ResponseText
Set objHttp = Nothing
这是来自 MAxMind 的 API,用于根据用户的 IP 获取用户的 city/zip。它正在工作,但我得到了这样的长线:
US,CA,Los Angeles,90068,34.134499,-328.190804,673,818,"AT&T U-verse"
知道如何打破这条线并从中获取某些值吗?
theArray = Split(objHttp.ResponseText,",")
for i=0 to uBound (theArray)
response.write theArray(i)
next
试试看。如果字符串始终采用相同的格式,则只需说 theArray(3)
即可获得第 4 个元素
我在 Classic ASP 中有以下代码:
Dim objHttp, strQuery
strQuery = "https://geoip.maxmind.com/f?333l=2112212&i=" & ipaddress
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.open "GET", strQuery, false
objHttp.send
Response.Write objHttp.ResponseText
Set objHttp = Nothing
这是来自 MAxMind 的 API,用于根据用户的 IP 获取用户的 city/zip。它正在工作,但我得到了这样的长线:
US,CA,Los Angeles,90068,34.134499,-328.190804,673,818,"AT&T U-verse"
知道如何打破这条线并从中获取某些值吗?
theArray = Split(objHttp.ResponseText,",")
for i=0 to uBound (theArray)
response.write theArray(i)
next
试试看。如果字符串始终采用相同的格式,则只需说 theArray(3)