dk4210
01-12-2012, 03:24 PM
Hello Guys,
I have a question
I have the following function that is located in a different file. I want to be able to use the $lat and $long in my main page how would I code it?
function toCoordinates($all_address)
{
$bad = array(
" " => "+",
"," => "",
"?" => "",
"&" => "",
"=" => ""
);
$all_address = str_replace(array_keys($bad), array_values($bad), $all_address);
$data = new SimpleXMLElement(file_get_contents("http://maps.google.com/maps/geo?output=xml&q={$all_address}"));
$coordinates = explode(",", $data->Response->Placemark->Point->coordinates);
return array(
"latitude" => $coordinates[0],
"longitude" => $coordinates[1]
);
}
Tried this but it didn't work
$all_address2 = toCoordinates($all_address);
echo "$all_address2;
Please advise...
Thanks, Dan
I have a question
I have the following function that is located in a different file. I want to be able to use the $lat and $long in my main page how would I code it?
function toCoordinates($all_address)
{
$bad = array(
" " => "+",
"," => "",
"?" => "",
"&" => "",
"=" => ""
);
$all_address = str_replace(array_keys($bad), array_values($bad), $all_address);
$data = new SimpleXMLElement(file_get_contents("http://maps.google.com/maps/geo?output=xml&q={$all_address}"));
$coordinates = explode(",", $data->Response->Placemark->Point->coordinates);
return array(
"latitude" => $coordinates[0],
"longitude" => $coordinates[1]
);
}
Tried this but it didn't work
$all_address2 = toCoordinates($all_address);
echo "$all_address2;
Please advise...
Thanks, Dan