Jump to content

Grabbing an array from a function


dk4210

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.