I am having a database table named "updates" which contains fields "id" and "post" which are of type 'int' and 'text' respectively. Now I am retrieving all posts as follows:
$result = mysqli_query($con,"SELECT post FROM updates");
while($row=mysqli_fetch_row($result)){
$postsarray[] = $row;
}
Now I want to convert this array into JSON array as follows:
{
"posts":[{
"post1",
"post2",
..
}]
}
I have tried many ways but could not get that. Can anyone help me doing that?
{starts an object, not an array.