Skip to content
Advertisement

MySQL select query and PHP convert as nested JSON object

I am try to retrieve unique object with nested object property and value, is there a possible way to retrieve as json object key and their child property and value

JavaScript

php code for json encoding result of array

JavaScript

Result php code

JavaScript

I want to retrieve with unique object key for year like this below

JavaScript

Advertisement

Answer

Just change your code a bit:

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