title: mysqli return json array from single sql table column
body: <p>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 <code>missing code</code> place in the code below.</p>
  
  <p>Desired result for example:</p>
  
  <p>users ["userA", "userB", "userC"];</p>
  
  <pre><code>&lt;?php
      require_once 'connection.php';
      $result = $conn-&gt;query("SELECT username FROM users");
      $users = array();
      // missing code
      $json = json_encode($users);
      echo $json;
  ?&gt;
  </code></pre>