I have this code below. The $address variable must get a string, in order to convert, and send it to a database. I have a form with inputs, which I store in further variables. How should i convert the values to get lat and long?
$address = "Rákoscsaba, Nagyréde utca 8. 1172"; // Google HQ
$prepAddr = str_replace(' ','+',$address);
$geocode=file_get_contents('https://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
It s working... the 3 variables I want to use: $user_telepules, $user_utca', $user_irsz
I've already tried these ways:
$address =['user_telepules'].','.['user_utca'].['user_irsz'];
$address =(string)$user_telepules.','.(string)$user_utca.(string)$user_irsz;
Ok, now I get it. Show us few data samples from this three variables. Maybe there is problem with something else, not string format.
How are you passing variables from input? Have you checked, if they actually exist and pass inputs from form?