Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do i get a value from simplexml_load_file?
    text
    copied!<p>Hello i need to print the long and lat values from Google Geocode. I have retrieved the xml using:</p> <pre><code>$url ="http://maps.googleapis.com/maps/api/geocode/xml?address=se18lu&amp;sensor=false"; $result = simplexml_load_file($url); </code></pre> <p>and it returns the following:</p> <pre><code>SimpleXMLElement Object ( [status] =&gt; OK [result] =&gt; SimpleXMLElement Object ( [type] =&gt; postal_code [formatted_address] =&gt; Bankside, London Borough of Lambeth, London SE1 8LU, UK [address_component] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [long_name] =&gt; SE1 8LU [short_name] =&gt; SE1 8LU [type] =&gt; postal_code ) [1] =&gt; SimpleXMLElement Object ( [long_name] =&gt; Bankside [short_name] =&gt; Bankside [type] =&gt; Array ( [0] =&gt; sublocality [1] =&gt; political ) ) [2] =&gt; SimpleXMLElement Object ( [long_name] =&gt; London [short_name] =&gt; London [type] =&gt; Array ( [0] =&gt; locality [1] =&gt; political ) ) [3] =&gt; SimpleXMLElement Object ( [long_name] =&gt; London Borough of Lambeth [short_name] =&gt; London Borough of Lambeth [type] =&gt; Array ( [0] =&gt; administrative_area_level_3 [1] =&gt; political ) ) [4] =&gt; SimpleXMLElement Object ( [long_name] =&gt; Greater London [short_name] =&gt; Gt Lon [type] =&gt; Array ( [0] =&gt; administrative_area_level_2 [1] =&gt; political ) ) [5] =&gt; SimpleXMLElement Object ( [long_name] =&gt; United Kingdom [short_name] =&gt; GB [type] =&gt; Array ( [0] =&gt; country [1] =&gt; political ) ) ) [geometry] =&gt; SimpleXMLElement Object ( [location] =&gt; SimpleXMLElement Object ( [lat] =&gt; 51.5034227 [lng] =&gt; -0.1080750 ) [location_type] =&gt; APPROXIMATE [viewport] =&gt; SimpleXMLElement Object ( [southwest] =&gt; SimpleXMLElement Object ( [lat] =&gt; 51.5020958 [lng] =&gt; -0.1094971 ) [northeast] =&gt; SimpleXMLElement Object ( [lat] =&gt; 51.5047938 [lng] =&gt; -0.1067991 ) ) [bounds] =&gt; SimpleXMLElement Object ( [southwest] =&gt; SimpleXMLElement Object ( [lat] =&gt; 51.5032242 [lng] =&gt; -0.1087301 ) [northeast] =&gt; SimpleXMLElement Object ( [lat] =&gt; 51.5036654 [lng] =&gt; -0.1075661 ) ) ) ) ) </code></pre> <p>All is good. i now need to retriave the long and tat values from the xml? how do i <strong>only</strong> print/show these values "lat"???: for example</p> <p>result->geometry->location->lat</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload