title: How to use a string as an array index path to retrieve a value?
body: <p>Let say I have an array like:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [Data] =&gt; Array
                  (
                      [id] =&gt; 1
                      [title] =&gt; Manager
                      [name] =&gt; John Smith
                  )
           )
      [1] =&gt; Array
          (
              [Data] =&gt; Array
                   (
                       [id] =&gt; 1
                       [title] =&gt; Clerk
                       [name] =&gt;
                           (
                               [first] =&gt; Jane
                               [last] =&gt; Smith
                           )
                   )
  
          )
  
  )
  </code></pre>
  
  <p>I want to be able to build a function that I can pass a string to that will act as the array index path and return the appropriate array value without using <code>eval()</code>. Is that possible?</p>
  
  <pre><code>function($indexPath, $arrayToAccess)
  {
      // $indexPath would be something like [0]['Data']['name'] which would return 
      // "Manager" or it could be [1]['Data']['name']['first'] which would return 
      // "Jane" but the amount of array indexes that will be in the index path can 
      // change, so there might be 3 like the first example, or 4 like the second.
  
      return $arrayToAccess[$indexPath] // &lt;- obviously won't work
  }
  </code></pre>