Jump to content

Recommended Posts

Hello,
First off, I'm new to PHP and trying to store values returned from a call to another site. I get the results in the following form:
Array
(
[ResultSet] => Array
(
[Result] => Array
(
[precision] => address
[Latitude] => 42.306295
[Longitude] => -83.244328
[Address] => 22000 MICHIGAN AVE
[City] => DEARBORN
[State] => MI
[Zip] => 48124-2353
[Country] => US
)

)

)

Now I would like to pull the values stored for Latitude and Longitude for comparison to other values I have to calculate distance between two points. I've looked all over and just can't seem to figure out how to access the values. I feel like an idiot because I'm sure there is a simple solution but have yet to be able to get it working. I can also get the serialized data if thats easier to work with.

Please help! I'm at a standstill. Thanks in advance for any help that may be provided!
-pk
Link to comment
https://forums.phpfreaks.com/topic/5711-solved-array-help/
Share on other sites

here is the code where I unserialize and pull the array contents to be displayed:

$phpobj2 = unserialize($response);

echo '<pre>';
print_r($phpobj2);
$temptest2 = print_r($phpobj2, true);

I tried

$st_lat=$temptest2['Latitude'];
printf("st_lat: %d ", $st_lat);

and that didn't work, the displayed value is '0'. If i try displaying it as a string it comes back as 'A'. Am I calling the right array name?

Thanks for the quick response!

Luke do you have AOL IM? my name is PKatMSU if you are online
Link to comment
https://forums.phpfreaks.com/topic/5711-solved-array-help/#findComment-20367
Share on other sites

Thanks for your help. That did it. I knew it was something stupid I was doing... For anyone who looks at this for help, here is the code that is the solution:

$st_lat = $phpobj2['ResultSet']['Result']['Latitude'];
$st_long = $phpobj2['ResultSet']['Result']['Longitude'];
Link to comment
https://forums.phpfreaks.com/topic/5711-solved-array-help/#findComment-20381
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.