Some help to parse a json file with php
Monkey Archive Forums/Monkey Discussion/Some help to parse a json file with php
| ||
Hi ! I'm searching a way to parse a json file with php and display the 'fcttext' value (all the json output here : http://api.wunderground.com/api/b99efd866a7db36a/forecast/lang:FR/q/FR/Castelnaudary.json ) So i've this php code : But i've not the value of fcttext inside $weather ! I'm not familiar with json_decode function ! Thanks for your help |
| ||
In the json you provide "forecastday" is a json array element, not an object, and the bit you're after is within "txt_forecast", not just "forecast". I'd imagine in the PHP output you'd need to deference the specific period element you want, so something like:$parsed_json->{"forecast"}->{"txt_forecast"}->{"forecastday"}[0]->{"fcttext"} |
| ||
Works fine now. Many thanks muddy_shoes. |