为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 php 中回显来自 geoip 数组的项目

如何在 php 中回显来自 geoip 数组的项目

PHP
当年话下 2023-04-23 17:40:54
我想分别从 geoplugin 数组中获取每个项目。这是我的示例代码 -$location_info = file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']);    echo$location_info;这里是数组中的响应a:24:{s:17:"geoplugin_request";s:12:"76.180.83.10";s:16:"geoplugin_status";i:200;s:15:"geoplugin_delay";s:3:"1ms";s:16:"geoplugin_credit";s:145:"Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.";s:14:"geoplugin_city";s:7:"Buffalo";s:16:"geoplugin_region";s:8:"New York";s:20:"geoplugin_regionCode";s:2:"NY";s:20:"geoplugin_regionName";s:8:"New York";s:18:"geoplugin_areaCode";s:0:"";s:17:"geoplugin_dmaCode";s:3:"514";s:21:"geoplugin_countryCode";s:2:"US";s:21:"geoplugin_countryName";s:13:"United States";s:14:"geoplugin_inEU";i:0;s:19:"geoplugin_euVATrate";b:0;s:23:"geoplugin_continentCode";s:2:"NA";s:23:"geoplugin_continentName";s:13:"North America";s:18:"geoplugin_latitude";s:7:"42.9297";s:19:"geoplugin_longitude";s:8:"-78.7434";s:32:"geoplugin_locationAccuracyRadius";s:1:"5";s:18:"geoplugin_timezone";s:16:"America/New_York";s:22:"geoplugin_currencyCode";s:3:"USD";s:24:"geoplugin_currencySymbol";s:5:"$";s:29:"geoplugin_currencySymbol_UTF8";s:1:"$";s:27:"geoplugin_currencyConverter";s:1:"1";}示例 - 我想获取城市并从此数组中回显它$city = ['geoplugin_city'];echo$city;
查看完整描述

1 回答

?
12345678_0001

TA贡献1802条经验 获得超5个赞

$location_info = unserialize($location_info);你忘了在连接后立即做。



查看完整回答
反对 回复 2023-04-23
  • 1 回答
  • 0 关注
  • 87 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信