note 106443 added to simplexmlelement.xpath
| From: | tnovak at modernagllc dot com | Date: | Wed, 09 Nov 2011 18:48:40 +0000 |
| Subject: | note 106443 added to simplexmlelement.xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184358@lists.php.net to get a copy of this message | ||
After hours of not finding anything of the sort. I wrote the following. It will pull the zip code
from google geocoding API using the lon and lat. It searches the google xml and returns the first
zip code found.
<?php
$xml = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?latlng='
. $userlon . ',' . $userlat . '&sensor=true');
$address_component = $xml->xpath('//address_component[type="postal_code"]');
$userzip = ($address_component[0]->long_name);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 166.233.47.94
----
Manual Page -- http://www.php.net/manual/en/simplexmlelement.xpath.php
Edit -- https://master.php.net/note/edit/106443
Del: integrated -- https://master.php.net/note/delete/106443/integrated
Del: useless -- https://master.php.net/note/delete/106443/useless
Del: bad code -- https://master.php.net/note/delete/106443/bad+code
Del: spam -- https://master.php.net/note/delete/106443/spam
Del: non-english -- https://master.php.net/note/delete/106443/non-english
Del: in docs -- https://master.php.net/note/delete/106443/in+docs
Del: other reasons-- https://master.php.net/note/delete/106443
Reject -- https://master.php.net/note/reject/106443
Search -- https://master.php.net/manage/user-notes.php