title: Why do I get 'Undefined offset: 0'?
body: <p>I'm develop a website and it looks fine.
  Then I turned on debugging to see if I had any errors, and I get this message:</p>
  
  <pre><code>Notice: Undefined offset: 0 in I:\path\to\file\MyFile.class.php on line 105
  </code></pre>
  
  <p>On that line you will find the following code:</p>
  
  <pre><code>$result = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  return $result[0]; // line 105
  </code></pre>
  
  <p>If I do a <code>print_r(result)</code> I get the following result:</p>
  
  <pre><code>Array (
      [0] =&gt; Array (
          [id] =&gt; 3721
          [parentID] =&gt;
      )
  )
  Array (
  ) 
  </code></pre>
  
  <p>As you can see the result contains twoarrays. The first one has data, the second one has no data. I've never seen <code>print_r</code> output two arrays like this. I'm guessing it's the second one causing me the problems.</p>
  
  <p>Can anyone advice me of why that second array sneaks in?</p>
  
  <p><strong>VAR dump</strong>  </p>
  
  <pre><code>array
    0 =&gt; 
      array
        'id' =&gt; string '3721' (length=4)
        'parentID' =&gt; null
  array
    empty
  </code></pre>