title: PHP JSON trying to get property of non-object error when looping
body: <p>I get this Error <code>Notice: Trying to get property of non-object</code> each time the array is at index 0.</p>
  
  <p>But works if there are more than 1 value in the array.  </p>
  
  <pre><code>$jsonurl = "https://example.org/json_response/";
  $json = file_get_contents($jsonurl,0,null,null);
  $json_output = json_decode($json, true);
  foreach ( $json_output as $output ) {   
    echo $output-&gt;id;
  }
  </code></pre>
  
  <p>Using <code>var_dump($json_output);</code> does returns the data. </p>
  
  <p><strong>Edited</strong></p>
  
  <pre><code>array (size=2)
    'id' =&gt; string 'xYue78ee9es' (length=10)
    'username' =&gt; string 'peesBEE' (length=7)
  </code></pre>
  
  <p>But throws Error when I try to accessing the variable like this <code>echo $output-&gt;id;.</code></p>