I am having a small problem, I am showing json using PHP, I have this code:
foreach($result as $r){
$returnEcho["Id"] = $r["id"];
$returnEcho["Username"] = $r["username"];
$returnEcho["Email"] = $r["email"];
$returnEcho["Info"] = $r["Info"];
echo json_encode($returnEcho);
The problem with this code is, it will display the JSON like this:
{"Username":"X","Email":"X","Info":"X"}
{"Username":"X","Email":"X","Info":"X"}
{"Username":"X","Email":"X","Info":"X"}
But what I want is something like this:
[
{
"Username":"X",
"Email":"X",
"Info":"X"
},
{
"Username":"X",
"Email":"X",
"Info":"X"
}
]
How can I do this? Thanks.