Navigating up through an array in PHP
<p>Given the following multi-dimensional array:</p>

<pre><code>$family = array(
    "grandfather",
    "grandmother",    
    "father" =&gt; array(
        "parents" =&gt; array(
            "grandfather",
            "grandmother"
         )
    ),
    "mother" =&gt; array(
        "parents" =&gt; array(
            "grandfather",
            "grandmother"
         )
    ),
    "son" =&gt; array(
        "parents" =&gt; array(
            "father",
            "mother"
         )
    ),
    "daughter" =&gt; array(
        "parents" =&gt; array(
            "father",
            "mother"
         )
    ),
);
</code></pre>

<p>You can imagine expanding this array to include great-grandparents, great-grandchildren, etc.</p>

<p>I'm sure this is a common and well documented data structure, but I'm not a computer science major and I don't know how to describe or name this particular type of dictionary.</p>

<p>Is there a function built in to PHP that will reliably navigate up this tree, given the name of a "child" node and an "ancestor" node that we are seeking?</p>

<p>For instance:</p>

<pre><code>getAncestor($array, $child, $ancestor);
</code></pre>

<p>I have tried this, and it usually involves recursion with the getAncestor() function nested inside itself, but will sometimes run into "dead ends", in which it will navigate all the way up to the end of one branch.</p>
