title: Undefined index from a foreach() loop
body: <p>ItemDb class</p>
  
  <pre><code>    public function getRandomItem() {
  
          $query = "SELECT * FROM `items` ORDER BY RAND() LIMIT 2";
          return $this-&gt;query($query);
  
      }
  </code></pre>
  
  <p>Index.php        </p>
  
  <pre><code>    $item = new Item();
  
      $result = $item-&gt;getRandomItem();
  
      while ($row = $result-&gt;fetch_assoc()) {
         foreach ($row as $key =&gt; $value) {
            //I want to put them in a array but the two items need to be separated 
         }
      }
  </code></pre>
  
  <p>I get two different items out of the database how can I split them and put them in one array separated like:</p>
  
  <p>$array[$key][$value]</p>
  
  <p>Sorry for my English its my second language and I hope you guys understand me.</p>