"; print ""; print "This is CS 50"; // iterate over hometowns foreach ($hometowns as $hometown) { // append hometown to URL $hometown = trim($hometown); if ($hometown == "") continue; $request = $url . "&q=" . urlencode($hometown); // get URL $contents = file_get_contents($request); // avoid apparent bug in Google's UTF-8 encodings $contents = utf8_encode($contents); // parse Google's XML $xml = simplexml_load_string($contents); // check status code $status = $xml->Response->Status->code; if ($xml->Response->Status->code == "200") { // get hometown's coordinates $coordinates = $xml->Response->Placemark->Point->coordinates; $latlng = split(",", $coordinates); $lat = $latlng [1]; $lng = $latlng[0]; // output Placemark print "\n"; print "$hometown\n"; print "$lng,$lat,0\n"; print "\n"; } // don't get blacklisted sleep(2); } // finish XML print ""; print ""; ?>