title: Accessing data from DB
body: <p>I'm getting data from database and putting it in a variable <code>$data</code>. If I'll <code>print_r($data)</code>, I'll get something like that:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [id] =&gt; 1
              [name] =&gt; Bob
          )
      [1] =&gt; stdClass Object
          (
              [id] =&gt; 2
              [name] =&gt; Mike
          )
  )
  </code></pre>
  
  <p>It has more <code>[key] =&gt; value</code> in each of them, and obviously it doesn't end on <code>[1]</code>.</p>
  
  <p>I'm using <code>foreach()</code> like that:</p>
  
  <pre><code>foreach ($data as $item) {
     foreach ($item as $key =&gt; $value) {
         //code
     }
  }
  </code></pre>
  
  <p>I have two question regards all the above:</p>
  
  <p>1) Is there less complex technique to get the <code>$key</code> and <code>$value</code>?</p>
  
  <p>2) If, for example, I want to output only the <code>[name]</code>, how would I access it? 
  The <code>$key[placeholder]</code> while placeholder is a number is outputting the letter number value of the <code>$key</code>.</p>