I'm getting PHP array from Here Maps:
array(1) {
["Response"] => array(2) {
["MetaInfo"] => array(1) {
["Timestamp"] => string(28)
"2020-04-26T17:28:14.089+0000"
} ["View"] => array(1) {
[0] => array(3) {
["_type"] => string(21)
"SearchResultsViewType" ["ViewId"] => int(0)["Result"] => array(1) {
[0] => array(5) {
["Relevance"] => float(1)["MatchLevel"] => string(11)
"houseNumber" ["MatchQuality"] => array(4) {
["Country"] => float(1)["City"] => float(1)["Street"] => array(1) {
[0] => float(0.9)
} ["HouseNumber"] => float(1)
} ["MatchType"] => string(12)
"pointAddress" ["Location"] => array(6) {
["LocationId"] => string(28)
"NT_uIrE4zNUPdurm.zAQNkxHA_0A" ["LocationType"] => string(7)
"address" ["DisplayPosition"] => array(2) {
["Latitude"] => float(52.14242)["Longitude"] => float(20.71666)
} ["NavigationPosition"] => array(1) {
[0] => array(2) {
["Latitude"] => float(52.14251)["Longitude"] => float(20.71668)
}
} ["MapView"] => array(2) {
["TopLeft"] => array(2) {
["Latitude"] => float(52.1435442)["Longitude"] => float(20.7148282)
} ["BottomRight"] => array(2) {
["Latitude"] => float(52.1412958)["Longitude"] => float(20.7184918)
}
} ["Address"] => array(10) {
["Label"] => string(38)
"ulica Rynek 4, 05-840 Brwinów, Polska" ["Country"] => string(3)
"POL" ["State"] => string(16)
"Woj. Mazowieckie" ["County"] => string(18)
"Powiat Pruszkowski" ["City"] => string(8)
"Brwinów" ["District"] => string(8)
"Brwinów" ["Street"] => string(11)
"ulica Rynek" ["HouseNumber"] => string(1)
"4" ["PostalCode"] => string(6)
"05-840" ["AdditionalData"] => array(3) {
[0] => array(2) {
["value"] => string(6)
"Polska" ["key"] => string(11)
"CountryName"
} [1] => array(2) {
["value"] => string(16)
"Woj. Mazowieckie" ["key"] => string(9)
"StateName"
} [2] => array(2) {
["value"] => string(18)
"Powiat Pruszkowski" ["key"] => string(10)
"CountyName"
}
}
}
}
}
}
}
}
}
}
To got array pasted above I'm using:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$string = curl_setopt($ch, CURLOPT_URL, "https://geocoder.ls.hereapi.com/6.2/geocode.json?&street=Rynek%204&city=Brwin%C3%B3w%20&country=Poland&gen=9&apiKey=MY_API_KEY");
$result=curl_exec($ch);
curl_close($ch);
$decoded=var_dump(json_decode($result, true));
I would like to get Latitude and Longitude from DisplayPosition. How I can do this?
I tried: var_dump ($decoded[1]["Response"][0]["View"][0]["Result"][0]["Location"]["DisplayPosition"]["Latitude"]);
but it won't helpt. I think I tried everything...
var_export($decoded). But your array starts with$decoded['Response']['View'][0]['Result'][0]...var_export($decoded);is giving meNULLecho var_export($decoded, true);? Does your array is named$decoded?echo var_export($decoded, true);I'm getting stillNULL