title: How to get latitude and longitude from address google map using php
body: <p>I have an Address and using that I want to fetch its exact Latitude and Longitude,</p>
  
  <p>but when I run my code it is giving me some other locations latitude and Longitude.</p>
  
  <p><strong>Output I want</strong></p>
  
  <p><a href="https://i.stack.imgur.com/oKqAH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKqAH.png" alt="enter image description here"></a></p>
  
  <p><strong>Output I am getting</strong></p>
  
  <p><a href="https://i.stack.imgur.com/LVFLy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LVFLy.png" alt="enter image description here"></a></p>
  
  <p>Please help me</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>&lt;?php
  $address = 'Cafe Coffee Day, INSIDE HPCL Petrol Bunk, Mumbai - Goa Highway,    
  Mangaon, Maharashtra, India'; 
  $prepAddr = str_replace(' ','+',$address);
  
  $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?     
  address='.$prepAddr.'&amp;sensor=false');
  
  $output= json_decode($geocode);
  
  // echo "&lt;pre&gt;";
  // print_r($output);
  
  $lat = $output-&gt;results[0]-&gt;geometry-&gt;bounds-&gt;northeast-&gt;lat;
  $long = $output-&gt;results[0]-&gt;geometry-&gt;bounds-&gt;northeast-&gt;lng;
  // $lati=round($lat,6);
  // $longi=round($long,6);
  
  echo $address.'&lt;br&gt;Lat: '.$lat.'&lt;br&gt;Long: '.$long;
  
  ?&gt;
  </code></pre>