2015-08-31 93 views
0

XML數據的內容試圖解決方案要獲取: -從PHP中的json獲取經度和緯度。未從那裏的緯度和經度是工作

<GetGPSRawDataResponse xmlns="http://xxxx.org/"><GetGPSRawDataResult>[{"IMIENO":"3xxxxxxxxxxxxxx","Lattitude":25.4286285,"Longitude":75.0507245,"Altitude":0.000,"Speed":0.000,"CTime":"Jul 8 2015 7:24:02:000PM","RecordTime":"Jul 9 2015 8:46AM","DevDistance":0.1000,"CardID":""},{"IMIENO":"3xxxxxxxxxxxxxx","Lattitude":25.4286285,"Longitude":75.0507245,"Altitude":0.000,"Speed":0.000,"CTime":"Jul 8 2015 7:19:02:000PM","RecordTime":"Jul 9 2015 8:49AM","DevDistance":0.0950,"CardID":""}]</GetGPSRawDataResult></GetGPSRawDataResponse> 

$ JSON = $ xmlObj-> GetGPSRawDataResult; //這將返回: -

[{"IMIENO":"3xxxxxxxxxxxxxx","Latitude":25.4286285,"Longitude":75.0507245,"Altitude":0.000,"Speed":0.000,"CTime":"Feb 8 2015 7:24:02:000PM","RecordTime":"Feb 9 2015 8:46AM","DevDistance":0.1000,"CardID":""},{"IMIENO":"3xxxxxxxxxxxxxx","Latitude":25.4286285,"Longitude":75.0507245,"Altitude":0.000,"Speed":0.000,"CTime":"Feb 8 2015 7:19:02:000PM","RecordTime":"Feb 9 2015 8:49AM","DevDistance":0.0950,"CardID":""}] 

然後我做: -

$json_decode=json_decode($json); 

但請幫我使用JSON獲取經度和緯度。我無法檢索它們的價值。請幫助我一個人。

回答

1

您是否試過下面的代碼?

foreach($json_decode as $row){ echo $row->Latitude echo $row->Longitude }

如果沒有作品,請您從$json_encode variable

+0

你是偉大的先生髮表的var_dump。我在過去的兩天裏一直在努力。但是無法找到解決方案,但是你以一種簡單的方式爲我解決了這個問題。真的非常感謝你。 – sakshi