Jump to content

Array Help, Serialize/unserialize


clarencek

Recommended Posts

Hi,

I'm using a Yahoo API to get geo data with the following php:

<?php

error_reporting(E_ALL);

// output=php means that the request will return serialized PHP
$request = 'http://api.local.yahoo.com/MapsService/V1/geocode?appid=infofornyc&street=701+First+Street&city=Sunnyvale&state=CA&output=php';

$response = file_get_contents($request);

if ($response === false) {
die('Request failed');
}

$phpobj = unserialize($response);

echo '<pre>';
print_r($phpobj);
echo '</pre>';


?>


The output of this is as below:

Array
(
[ResultSet] => Array
(
[Result] => Array
(
[precision] => address
[warning] => The exact location could not be found, here is the closest match: 701 First Ave, Sunnyvale, 94089
[Latitude] => 37.416384
[Longitude] => -122.024853
[Address] => 701 FIRST AVE
[City] => SUNNYVALE
[State] =>
[Zip] => 94089-1019
[Country] => US
)

)

)

This is probably a simple newbie question, but how do I access just the Latitude number? I want to grab that number and stick it in a mySQL database.

I thought it would be something like:

echo $phpobj[ResultSet[Result[1]]];

How do I access that variable.
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.