Skip to content
Advertisement

PHP load json data, output is empty

I try to load data from my JSON file into php see my code below

JSON:

JavaScript

PHP:

JavaScript

If I run this code my output is empty. Who can help me in the right direction?

Advertisement

Answer

Your JSON input is NOT valid according to RFC 4627 (JSON specification). So the correct json string must be:

JavaScript

so your code would work:

JavaScript

Or at least, you must format your json string like below:

JavaScript

And you can get your data in this way:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement