title: PHP multidimensional array to json echoes only the first result
body: <p>i am writing an API for an online service I am developing, the code below should get the data from the db and structure it somewhat like this:</p>
  
  <pre><code>{
      data: [
              {
                      name: [
                              "xxx"
                      ],
                      description: [
                              "xxx"
                      ],
                      event_date: [
                              "xxx"
                      ],
              }
              {
                      name: [
                              "yyy"
                      ],
                      description: [
                              "yyy"
                      ],
                      event_date: [
                              "yyy"
                      ],
              }
      ]
   }
  </code></pre>
  
  <p>but instead, it is showing up like this:</p>
  
  <pre><code>{
      data: [
              {
                      name: [
                              "xxx"
                      ],
                      description: [
                              "xxx"
                      ],
                      event_date: [
                              "xxx"
                      ],
              }
      ]
   }
  </code></pre>
  
  <p>i have no idea what i'm doing wrong, surely it has to be something stupid simple...</p>
  
  <p>here's the code:</p>
  
  <pre><code>if($result) {
  
    $i = 0;
    $x = 0;
  
    $results_main_array['data'] = array();
    $description_array = array("name", "description", "event_date", "location", "photos", "logo", "video");
    $results_array = array();
  
    while($row = $result-&gt;fetch_array(MYSQLI_NUM)) {
  
      foreach($row as $r) {
  
        if($i &gt;= count($row)) {
          $i = 0;
  
          array_push($results_main_array['data'], $results_array);
        }
  
        $results_array[$description_array[$i]] = array($r);
  
        ++$i;
      }
    }
  
    echo json_encode($results_main_array);
  } else {
  
    echo "else";
  }
  </code></pre>