I'm pretty sure I'm quite close so hopefully quick answer.
I'm able to generate this JSON:
apps: [
{
0: {
PublisherCount: "7"
},
Id: "87",
AppName: "Productivity, Focus, Habits & Life Success by Audiojoy",
AppBundle: "productivitymind"
}
]
But I'm trying to get to:
apps: [
{
Id: "87",
AppName: "Productivity, Focus, Habits & Life Success by Audiojoy",
AppBundle: "productivitymind",
PublisherCount: "7"
}
]
Here is my output loop (I think the issue is in the 5th row where I array_push the new value for PublisherCount
. It creates an additional node instead of adding it to the end.
$temp_array = array();
$i = 0;
while ($row = mysqli_fetch_assoc($publisher_apps)) {
$temp_array[] = $row;
$temp_array[$i][] = fetch_all(get_publisher_count_by_app_id($row['Id']))[0];
$i++;
}
$publisher_apps = $temp_array;
$result = array("apps"=>$publisher_apps);
output_json($result);
Thanks.