title: Convert JSON arrays to JSON format
body: <p>I am having a problem converting JSON arrays to JSON format data, Currently I am getting my output in this format:</p>
  
  <p><a href="https://i.stack.imgur.com/SW2NW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SW2NW.png" alt="enter image description here"></a></p>
  
  <p>But I want to have my output in this format:</p>
  
  <p><a href="https://i.stack.imgur.com/MuCSS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MuCSS.png" alt="enter image description here"></a></p>
  
  <p>Here is the code I am using: </p>
  
  <pre><code>    &lt;?php
  
  // Create connection
  $conn = mysqli_connect("127.0.0.1","root","", "testapp");
  
  $sql = "SELECT * FROM timetable";
  
  $result = mysqli_query($conn, $sql);
  
      $rows = array();
      while ($row = mysqli_fetch_assoc($result)) {
  
              $rows[] = $row; 
  
      }
  
  echo json_encode($rows);
  
  
  echo "&lt;pre&gt;";
  print_r($rows);
  echo "&lt;/pre&gt;"; 
  
  ?&gt;
  </code></pre>