Hello, how are you?
I'm getting the values from a table in a database and "transforming" them into JSON. I have the following PHP code:
$sql = "SELECT * FROM pessoas";
$query = mysqli_query($mysqli, $sql);
$arr = array();
while ($dados = mysqli_fetch_assoc($query)) {
$arr['nome'] = $dados['nome'];
$arr['sobrenome'] = $dados['sobrenome'];
}
return json_encode($arr);
However, it only returns me
{"nome":"Leo","sobrenome":"Nerone"}
But I would like it to return everything, for example:
{"nome":"Leo","sobrenome":"Nerone"},
{"nome":"Alguem","sobrenome":"Loco"}
How to do this?