本文介绍了使用经典ASP的字符串到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Classic ASP中具有以下代码:
I have the following code in 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获取用户所在的城市/邮政编码.它正在工作,但我的电话很长:
It's an API from MAxMind to get the city/zip of a user per his IP. It's working but I get a long line like this:
有什么主意,我该如何打破这行界限并从中获得某些价值?
Any idea how can I break this line and take from it certain values?
推荐答案
theArray = Split(objHttp.ResponseText,",")
for i=0 to uBound (theArray)
response.write theArray(i)
next
尝试一下.如果字符串始终采用相同的格式,则只需说出theArray(3)
Try that. if the string is always in the same format, you can get the 4th element simply by saying theArray(3)
这篇关于使用经典ASP的字符串到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!