0

I'm a beginner on php. This document is the result of a mongodb query.

Array ( [_id] => MongoId Object ( [$id] => 55e994585bab8c0a816e0693 ) [metadata] => Array ( [timestamp] => 1441371224596 ) [message] => Array ( [itsPduHeader] => Array ( [messageID] => 1 [protocolVersion] => 1 [stationId] => 33000 ) [denm] => Array ( [managementContainer] => Array ( [relevanceDistance] => 3 [referenceTime] => 363373455171 [stationType] => 15 [actionID] => Array ( [sequenceNumber] => 69 [orignatorStationID] => 33000 ) [detectionTime] => 363373438142 [eventPosition] => Array ( [altitude] => Array ( [altitudeValue] => 0 [altitudeConfidence] => 15 ) [posConfidenceEllipse] => Array ( [semiMajorOrientation] => 3601 [semiMinorConfidence] => 4095 [semiMajorConfidence] => 4095 ) [latitude] => 448848419 [longitude] => -5615145 ) ) [situationContainer] => Array ( [informationQuality] => 0 [eventType] => Array ( [subCauseCodeType] => 0 [causeCodeType] => 1 ) ) [locationContainer] => Array ( [traces] => Array ( [0] => Array ( [0] => Array ( [pathPosition] => Array ( [deltaAltitude] => 0 [deltaLongitude] => 0 [deltaLatitude] => 0 ) ) ) ) ) ) ) )

But I can't get the value of latitude and longitude. Can anybody help me?

7
  • 1
    possible duplicate of How to read json properties using PHP Commented Sep 7, 2015 at 7:29
  • We need to decode the JSON value. check this URL [stackoverflow.com/questions/12429029/… Commented Sep 7, 2015 at 7:46
  • it's not all ready decoded? Commented Sep 7, 2015 at 7:53
  • $doc = json_decode($doc, true); returns NULL Commented Sep 7, 2015 at 7:59
  • php.net/manual/en/… if in doubt check the doc Commented Sep 7, 2015 at 22:40

1 Answer 1

0

Try:

$result = array();
echo $result['message']['denm']['managementContainer']['eventPosition']['latitude'];
echo $result['message']['denm']['managementContainer']['eventPosition']['longitude'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.