clarencek Posted June 28, 2006 Share Posted June 28, 2006 Hi,I'm using a Yahoo API to get geo data with the following php:<?phperror_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 https://forums.phpfreaks.com/topic/13139-array-help-serializeunserialize/ Share on other sites More sharing options...
Buyocat Posted June 28, 2006 Share Posted June 28, 2006 This will look a little messing, but I'm sure you can make it cleaner:$phpobj['ResultSet']['Result']['Latitude']because it is an associative array you must use the corresponding string keys. Link to comment https://forums.phpfreaks.com/topic/13139-array-help-serializeunserialize/#findComment-50533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.