I want to save the geographic coordinates of an address, in the database. I can do this, but have one though.
I have a function that takes an address and returns the geographical coordinates of it. The problem is that as the function has an "echo" to display the coordinates and it is locking my application. Do you know how to do this function return the result without being "echo" or do you know how to make the application not "stop" when passing through "echo"?
Follow the function:
function getCoordinates($address){
$address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
$response = file_get_contents($url);
$json = json_decode($response,TRUE); //generate array object from the response from the web
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}
echo getCoordinates($address);