function get_city($ip = null) { $cities = option_category('city', false, true); $ip = $ip ? $ip : Utility::GetRemoteIP(); $location = ip_location_youdao($ip); if ($location) { foreach ($cities as $one) { if (FALSE !== strpos($location, $one['name'])) { return $one; } } } return array(); }
public function test() { $ip = get_client_ip(); dump(ip_location_youdao($ip)); }