JSON-PHP:parse multiple object with the same name -


I have this problem: I am trying to display weather information from weather and I am getting this response Is:

  {"response": {"version": "0.1", "termsof service": "http://www.wunderground.com/weather/api/d/terms "{Date}": "predicted": {"forecast": 1}}, "forecast": {"txt_forecast": {"date": "10:52 cst", "approximate date": [{"period": 0, "Icon": "Toasts", "Icon_url": "http://icons.wxug.com/i/c/k/tstorms.gif", "Title": "Wonderidee", "FTPText": "Temorouli Max. : 79ºF Venti da s "Pipoia: 80%", "pop": "80"}, {"duration": 1, "icon": "nt_rain", "icon_url": "http://icons.wxug.com/i /c/k/nt_rain.gif "," title ":" wernerie note "," fttext ":" piagia e tuano min: 62 ff. Venti da ANE Vairabili Propy PioGiya: 60%. "," FTXxMetric ":" Peugeot eu tuoini minimum: 17ºC. Venti da ANE Vairabili Problem. Pogoia: 60%. "," Pop ":" 60 "}, {" duration ": 2," icon ":" toasts "," icon_url ":" http://icons.wxug.com/i/c/ K / tstorms.gif "," Title ":" Subto "," FTPText ":" Temorouli Max: 75ºF. Venti da SSE variation Problem. Peugeot: 90%. "," FTTXT Metric ":" Temorouli Max: 24ºC Venti da SSE Welfare Problem. Using this code:  
  & lt ;? Php $ json_string = file_get_contents ("pioggia: 90%", "pop": "90"}  

http://api.wunderground.com/api/***/forecast/ Lang: IT / q / SW / Lugano.json "); $ parased_json = json_decode ($ json_string); $ date = $ parsed_json- & gt; {'forecast'} - & gt; {'txt_forecast'} - & gt; {'Date'}; $ named = $ parsed_json- & gt; {'forecast'} - & gt; {'txt_forecast'} - & gt; {'prediction'} -> {'title'}; $ txtd0 {$ Predse_json- & gt; {'forecast'} - & gt; {'txt_forecast'} - & gt; {'day of forecast'} - & gt; {'fcttext'}; echo "$ name0, $ date: $ Txtd0 ";? & Gt;

(I want to do something like this: Friday, 10: 52CEST: rainy day ...)

But problem Is that i The expression can not be displayed because the values ​​of the second period (period: 1) are similar to the first names.

I tried to insert the link but it only shows me this: ...

  "Forecasting duration": [["Duration": 0, "icon": "Toasts", "Icon_url": "http://icons.wxug.com/i/c/k /tstorms.gif "," title ":" wernerie "," fttext ":" Temorouli max: 79ºF. Venti da S Wabirabili Problem. Pyogia: 80%. "," FTTeTest_Metric ":" Temorouli Max: 26 degree C Venti da S Wabirabili Problem. Pioggia: 80%. "," Pop ":" 80 "}, {}, {}, {}, {}, {}, {}, {}  

So the question is, How to distinguish a different term:

  Duration: $ Named, $ date: $ txtd0 Duration 1: $ name1, $ date: $ txtd1 ....  < / Pre> 

Because there is no way to get the first or second 'title' of the response in the code

  $ name0 = $ parse_json- & gt; {'forecast'} - & Gt; {'txt_forecast'} - & gt; {'Predict date'} - & gt; {'title'};  

named $ Should get the value of the first 'title'

Sorry for my English and my coding skills, I am still a newbie.

'predictor' Is decoded as an array, so ypou can access it like this:

  $ name1 = $ parse_json- & gt; prediction- & gt; prediction [1] - & Gt; name;  

I have not used your signaling (can be tried:

  $ name1 = $ parse_json- & gt; {'Predictions'} - & gt; {'Txt_forecast'} - & gt; {'Predict'} [1] - & gt; { 'Title'};  

(The brackets do not go into string / the '...') However, the prediction is an array, other things are ...


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -