title: How would I be able to create brackets around my json file using PHP?
body: <pre><code>function get_data()
  {
      $connect = mysqli_connect("localhost", "root", "root", "Database");
      $query = "SELECT * FROM Furniture";
      $result = mysqli_query($connect, $query);
      $categories = array();
  
      $row = mysqli_fetch_array($result);
  
  {
          $categories[] = array(
  
          'mapwidth' =&gt; "2000",
          'mapheight' =&gt; "2000",
  
  
         );            
   }
  </code></pre>
  
  <p>This is what I have so far, but how would I be able to create an array of "categories" so that the json file looks like this,</p>
  
  <pre><code>{
      "mapwidth": "2000",
      "mapheight": "2000",
      "categories": [
      {
          "id": "furniture",
          "title": "furniture",
          "color": "#4cd3b8",
          "show": "false"
      },
      {
          "id": "rooms",
          "title": "Rooms",
          "color": "#63aa9c",
          "show": "true"
      }
      ],
  </code></pre>
  
  <p>I tried to do this but I was only able to get one row to display but am not sure how to iterate through the database so that every row will display the "id", "title", "color", and "show" within the brackets as seen in the json file. So I pretty much just want the json file to look exactly like the one shown here. </p>