I have a mysql database, I want to change it to json format with results like the one below
["aaa","bbb","ccc"]
but when I made the code using PHP as below
<?php
require_once("../con.php");
$list = mysqli_query($con,"SELECT * FROM user WHERE reff='admin'");
$r = array();
while($data = mysqli_fetch_array($list)) {
$r[] = array($data['username']);
}
echo json_encode($r, JSON_PRETTY_PRINT);
?>
the results are different from what I want, the following results
[ [ "aaa" ], [ "bbb" ], [ "ccc" ] ]
is there any suggestion how to fix it?
$r[] = array($data['username']);with this one$r[] = $data['username'];