Saturday 15 March 2014

PHP turning json into array -


So I've got this large amount of data in a php-file, but it's in Jason-format.

I have tried to convert all json to a $ string variable to change it. Then:

  $ json = json_decode ($ string); Forex currency ($ json => $ value as the $ key) {echo $ value; }   

However this does not work, so how am I doing this loss so that I can put it in a mysql-database instead of all the data (or arrays).

This is a small part of the data. Wrong, "Freetextbox": [/ p> True, "Started": "Started": "-" "", True, "code": "680378", "LAN": "We \ u00e4stra g \ u00f6talands l \ u00e4n", "WeekdraftDownList": True, "TypeDropDownList" True, "Code": "", "LAN": "", "School Id": "29320", "Stadium": "Stockholm", "Periodontropdualist": True, "Free Textbox" : "Stockholm True, "Started": "8:15"}]

All of this depends on the correct JSON, but your example code generates an array of objects, which is why the echo does not work is. / P>

Something like this should work with your example:

  $ json = json_decode ($ string); Forex currency ($ json => $ value as the $ key) {echo $ value- & gt; Name; }    

No comments:

Post a Comment