本文介绍了使用经典 ASP 的字符串到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在经典 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:

US,CA,Los Angeles,90068,34.134499,-328.190804,673,818,"AT&T U-verse"

知道如何打破这条线并从中获取某些值吗?

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 的字符串到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 08:51