title: PHP JSON get the name of an object
body: <pre><code>&lt;?
  stdClass Object
  (
      [image_header] =&gt; Array
          (
              [0] =&gt; stdClass Object
                  (
                      [img] =&gt; /headers/header.jpg
                  )
          )
  )
  ?&gt;
  </code></pre>
  
  <p>Object name image_header is variable, so it can be any string. Can I access this string without knowing what it is? </p>
  
  <p>@Jon his answer was satisfying for me.</p>
  
  <p>For others who want to use variable objectnames this way: 
  To acces this object with the variablename I had to use curly brackets:</p>
  
  <pre><code>$key = key(get_object_vars($_json));
  $_json-&gt;{$key}[0]-&gt;img;
  </code></pre>