I'd like to convert a complex array in a simple json object. I know how to convert an array into json (json_encode) but my problem is how I could convert my basic array into the following json structure.
Array structure :

Json Output :
{
"id": "1",
"name": "Random Access Memories",
"tracks": [
{
"id": 1,
"name": "Get Lucky",
"artists": [
{
"id": 1,
"name": "Daft Punk"
},
{
"id": 2,
"name": "Pharrell Williams"
}
]
},
{
"id": 1,
"name": "Touch",
"artists": [
{
"id": 1,
"name": "Daft Punk"
}
]
}
],
"album_artists": [
{
"id": 1,
"name": "Daft Punk"
},
{
"id": 2,
"name": "Pharrell Williams"
}
]
}