I am trying to create an array so i can print it in json format. I am querying a database using mysqli so and in the fetch loop sticking the returned information in an array, and trying to stick all of the arrays returned into one array and print that array in json format, but i cant seem to do it. here is my code, any help or insight would be vastly appreciated.
while($stmt->fetch())
{
$array .= ("title"=>$title,"date"=>$date,"body"=>$body)
}
print_r(json_encode($array));
but what is printed is
ArrayArrayArrayArrayArray
can anyone please help?
Use the
[]syntax to append a new element onto your array$arrayEdited. Originally missed that this used MySQLi bound variables, rather than a fetched row.