I am selecting a single column from an SQL table. I want to get as result an array of usernames in json. I don't know what to write in the missing code place in the code below.
Desired result for example:
users ["userA", "userB", "userC"];
<?php
require_once 'connection.php';
$result = $conn->query("SELECT username FROM users");
$users = array();
// missing code
$json = json_encode($users);
echo $json;
?>
$users = $result->fetch_all(MYSQLI_NUM);