How to get latitude and longitude by address in PHP

function getLatLong($address){
if (!is_string($address))die(“ERROR! – Invalid Address!”);
$_url = sprintf(‘http://maps.google.com/maps?output=js&q=%s’,rawurlencode($address));
$_result = false;
if($_result = file_get_contents($_url)) {
if(strpos($_result,’errortips’) > 1 || strpos($_result,’Did you mean:’) !== false) return false;
preg_match(‘!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U’, $_result, $_match);
$_latlong [‘lat’] = $_match[1];
$_coords[‘long’] = $_match[2];
}
return $_coords; // returns an array $_coords[‘lat’], $_coords[‘long’]
} 

$address = ‘Address’; // Put Your address here 
$latlong = getLatLong($address);

//Latitude
$lat = $latlong [‘lat’];
$long  =$latlong [‘long’]

How to get Address by latitude and longitude

Use Function below to get address  
function getaddress($lat,$lng)
{
$url = ‘http://maps.googleapis.com/maps/api/geocode/json?latlng=’.trim($lat).’,’.trim($lng).’&sensor=false’;
$json = @file_get_contents($url);
$data=json_decode($json);
$status = $data->status;
if($status==”OK”)
return $data->results[0]->formatted_address;
else
return false;
}

echo getaddress($lat,$lng);

What is File structure of WordPress theme

File structure of WordPress theme

The main files used in wordpress are:- 

  1. index.php :- for index page.
  2. single.php :- for single post page.
  3. page.php :- display the static pages.
  4. category.php :-  Display the category page.
  5. archive.php :- For archive page display.
  6. tag.php :- For display the tags page.
  7. author.php :- For display author page.
  8. search.php :- For display the search result page.
  9. 404.php :- For display 404 error page.
  10. taxonomy.php :- For display the taxonomy archive.
  11. attachment.php :- For managing the single attachments page.
  12. header.php :- For managing top part of page.
  13. footer.php :- For manage bottom part of pages.

PHP: how to convert a string to an array in php