[Solved] programatically search a place in google map API by passing place name


using JSON

<?php
function geoPlaceID($location)
{
   $locationclean = str_replace (" ", "+", $location);
   $details_url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" . $locationclean . "&key=YOUR_KEY";
   $du = file_get_contents($details_url);

   $getDetails = json_decode(utf8_encode($du),true);
   if ($getDetails['status']=="OK")
   {
       $a=$getDetails['results'][1]['types'];
       print_r($a);
      // echo implode(" ",$a)."<br>";
   }
   else
   {
       echo "Place ID not found";
   }
}
geoPlaceID("kfc");
 ?>

using XML

<?php

function place_ID($location)
{
$locationclean = str_replace (" ", "+", $location);
$data = "https://maps.googleapis.com/maps/api/place/textsearch/xml?query=" . $locationclean . "&key=YOUR_KEY";

$xml = file_get_contents($data);
$xml = simplexml_load_string($xml);

foreach($xml->result->type as $key => $value){
    $location_id = $value;
    echo $location_id;
    echo "<br>";
}
}
place_ID("kfc");

?>

solved programatically search a place in google map API by passing place name