title: PHP Simple way to obtain value from multi level object
body: <p>I know I can loop through each level of the object, but I would like a more simple approach to this.</p>
  
  <pre><code>QueryResult Object
  (
      [queryLocator] =&gt; 
      [done] =&gt; 1
      [records] =&gt; Array
          (
              [0] =&gt; SObject Object
                  (
                      [type] =&gt; type_1
                      [fields] =&gt; 
                      [sobjects] =&gt; Array
                          (
                              [0] =&gt; SObject Object
                                  (
                                      [type] =&gt; type_2
                                      [fields] =&gt; 
                                      [sobjects] =&gt; Array
                                          (
                                              [0] =&gt; SObject Object
                                                  (
                                                      [type] =&gt; type_3
                                                      [fields] =&gt; 
                                                      [sobjects] =&gt; Array
                                                          (
                                                              [0] =&gt; SObject Object
                                                                  (
                                                                      [type] =&gt; type_4
                                                                      [fields] =&gt; 
                                                                      [sobjects] =&gt; Array
                                                                          (
                                                                              [0] =&gt; SObject Object
                                                                                  (
                                                                                      [type] =&gt; type_5
                                                                                      [fields] =&gt; 
                                                                                      [Id] =&gt; 12345_I_need_this
                                                                                  )
  
                                                                          )
  
                                                                  )
  
                                                          )
  
                                                  )
  
                                          )
  
                                  )
  
                          )
  
                  )
  
          )
  
      [size] =&gt; 1
  )
  </code></pre>
  
  <p>I need this Id value of type_5, how could I get this in a simple solution.</p>
  
  <p>Some other points to think about:</p>
  
  <ul>
  <li>I will not know how big or how deep the object of arrays will go, could be more or less than 5</li>
  </ul>
  
  <p>I have heard about recursion but havn't found anything I think I could use that keeps it simple. Maybe some better tutorials would help me out.
  If I did know in what part of the array of object the value I neede was in could I just call it directly? something like: $object[5]->id ??? </p>