This might be an easy one but I'm struggling to get it done.
I have this following array in php which I want to json_encode as an array of objects. What's the best way of doing this in php?
Array
(
[6946] => Array
(
[AssetGroupName] => Computer
[AssetGroupID] => 14
)
[6945] => Array
(
[AssetGroupName] => Laptop
[AssetGroupID] => 15
)
)
Json output I'm trying to get.
{
"data": [
{
"AssetGroupName": "Computer",
"AssetGroupID": "12"
},
{
"AssetGroupName": "Laptop",
"AssetGroupID": "15"
}
]
}
json_encode()will encode an associative array as a JSON object.