1
나는 순간에 다음과 같은 코드가 있습니다의 PHP DOMDocument를 변수
$ip = '195.72.186.157';
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML(file_get_contents('http://www.geoffmeierhans.com/services/geo-locator/locate/?ip='.$ip.'&output=xml'));
foreach($xmlDoc->getElementsByTagName('city') as $link) {
$links = array('text' => $link->nodeValue);
}
$city = $links['text'];
echo $city;
도시 변수를 얻을 수있는 더 나은 방법이 있나요를? 이 루프가 정말 필요하지 않은 도시라는 하나 개의 태그하지만 난 그것을 다른 방법
당신은 첫 번째 결과를합니다. – Gordon